Skip to content

Instantly share code, notes, and snippets.

View hesselink's full-sized avatar

Erik Hesselink hesselink

View GitHub Profile
function f (x)
{
var y = x;
Array.prototype.shift.call(arguments);
return x + y;
}
f(1, 2); // Returns 3, not 2.
@hesselink
hesselink / gist:704109
Created November 17, 2010 21:21
Datatype versioning using type families
{-# LANGUAGE EmptyDataDecls
, TypeFamilies
, MultiParamTypeClasses
, FlexibleContexts
, FlexibleInstances
, UndecidableInstances
, ScopedTypeVariables
#-}
import Control.Applicative
@hesselink
hesselink / gist:775990
Created January 12, 2011 10:31
Applicative algebras
{-# LANGUAGE GADTs, KindSignatures #-}
import Prelude hiding (length, sum)
import Control.Applicative
import Control.Arrow
newtype Fix f = In { out :: f (Fix f) }
data Alg :: (* -> *) -> * -> * -> * where
@hesselink
hesselink / ExtensibleRecords.hs
Created April 25, 2012 20:05
Extensible records with data kinds
{-# LANGUAGE
GADTs
, KindSignatures
, DataKinds
, PolyKinds
, TypeOperators
, TypeFamilies
, MultiParamTypeClasses
, FlexibleInstances
, UndecidableInstances
@hesselink
hesselink / gist:3757658
Created September 20, 2012 18:53
Indexed functor and monad classes for common monad transformers
{-# LANGUAGE Rank2Types #-}
import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Reader
import Control.Monad.Trans.State
import Control.Monad.Trans.Writer
import Data.Monoid
@hesselink
hesselink / gist:3769836
Created September 23, 2012 11:34
Mapping over errors
{-# LANGUAGE TypeFamilies, FlexibleInstances #-}
import Control.Monad.Error
import Control.Monad.Reader
type family MappedMonad (m :: * -> *) e' :: * -> *
type instance MappedMonad (ErrorT e m) e' = ErrorT e' m
type instance MappedMonad (ReaderT r m) e' = ReaderT r (MappedMonad m e')
class MapError m where
type ErrorType m :: *
alert("boom")
#!/usr/bin/env python2
"""
Uploads haddocks to Hackage.
Use it when Hackage can't build your documentation (e.g. missing libraries).
Inspired by:
http://fuuzetsu.co.uk/blog/posts/2014-01-06-Fix-your-Hackage-documentation.html
"""
import getpass