Skip to content

Instantly share code, notes, and snippets.

@blouerat
Last active August 29, 2015 14:02
Show Gist options
  • Save blouerat/2b9437a745f46b21a02b to your computer and use it in GitHub Desktop.
Save blouerat/2b9437a745f46b21a02b to your computer and use it in GitHub Desktop.
1HaskellADay: iso1
{-# LANGUAGE TupleSections #-}
-- Follow the type and the properties
f :: Either a a -> (Bool, a)
f = either (False,) (True,)
g :: (Bool, a) -> Either a a
g (False, a) = Left a
g (True, a) = Right a
g' :: (Bool, a) -> Either a a
g' = uncurry $ cata Right Left
where cata :: a -> a -> Bool -> a
cata a _ True = a
cata _ a False = a
-- |
-- prop> (f . g) x == x
-- prop> (g . f) x == x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment