Skip to content

Instantly share code, notes, and snippets.

@patrickt
Created June 3, 2014 18:56
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 patrickt/c513df8360fff66f0fe0 to your computer and use it in GitHub Desktop.
Save patrickt/c513df8360fff66f0fe0 to your computer and use it in GitHub Desktop.
data Either a b = Left a | Right b
isLeft :: Either a b -> Bool
isLeft (Left _) = True
isLeft _ = False
either :: (a -> c) -> (b -> c) -> Either a b -> c
either f _ (Left x) = f x
either _ g (Right y) = g y
lefts :: [Either a b] -> [a]
lefts x = [a | Left a <- x]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment