Skip to content

Instantly share code, notes, and snippets.

@kindlychung
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kindlychung/bf4003104dbc28ac548b to your computer and use it in GitHub Desktop.
Save kindlychung/bf4003104dbc28ac548b to your computer and use it in GitHub Desktop.
learn you a haskell
on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
f `on` g = \x y -> f (g x) (g y)
instance Functor (Either a) where
fmap f (Right x) = Right (f x)
fmap f (Left x) = Left x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment