Skip to content

Instantly share code, notes, and snippets.

@merijn
merijn / DropAt.hs
Created June 12, 2015 19:41
dropAt
dropAt :: Int -> [a] -> [a]
dropAt = go id
where
go :: ([b] -> [b]) -> Int -> [b] -> [b]
go f n [] = f []
go f 0 (x:xs) = f xs
go f n (x:xs) = go (f . (x:)) (n-1) xs
@merijn
merijn / Scraper.hs
Created July 9, 2015 08:20
Concurrent webscraper
{-# LANGUAGE OverloadedStrings #-}
import Control.Concurrent.Async
import Control.Concurrent.QSem
import Control.Monad
import Control.Monad.Catch
import Control.Monad.Trans
import Control.Monad.Reader
import Data.ByteString.Lazy (ByteString)
@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

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

@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