Skip to content

Instantly share code, notes, and snippets.

@merijn
merijn / FizzBuzz.hs
Last active January 24, 2019 08:57
Generalised FizzBuzz
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Control.Monad (forM_)
import Data.Maybe (fromMaybe)
generalisedFizzBuzz
:: forall a f m
. (Foldable f, Semigroup m)
=> (a -> m) -> (a -> a -> Bool) -> f (a, m) -> a -> m
#include <stdio.h>
int main(int argc, char **argv)
{
int d = sizeof(0)["ABCDEFGHIJKLMNOPQRSTUWVXYZ"];
printf("%d\n", d);
return 0;
}
@merijn
merijn / MyState.hs
Last active January 15, 2021 19:20
MyState homework
data MyState s a = MyState (s -> (a, s))
get :: MyState s s
get = undefined
put :: s -> MyState s ()
put = undefined
modify :: (s -> s) -> MyState s ()
modify = undefined
@merijn
merijn / wat.c??
Created February 26, 2021 10:13
C vs C++
#include <stdio.h>
char X = 'a';
int main(int argc, char* argv[])
{
(void) argc;
(void) argv;
struct X {
import Foreign
main :: IO Int
main = peek nullPtr

Why You Should Stop Saying "Concrete Type"!

TL;DR: There is no concrete (hah!) definition of "concrete type", different people are meaning different things by those words and assuming everyone else means the same thing.

A Quick Type Primer

The Cabal/Stack Disambiguation Guide

One of the most frequently asked Haskell beginner questions in recent years is:

"Stack or cabal?"

I will helpfully not answer this question. Instead I will hope to eliminate the confusion that many of the askers seem to have about the various different