Skip to content

Instantly share code, notes, and snippets.

@scalolli
Created June 27, 2018 06:03
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 scalolli/01eb0b4bf1069d1e976b4a548dbcb016 to your computer and use it in GitHub Desktop.
Save scalolli/01eb0b4bf1069d1e976b4a548dbcb016 to your computer and use it in GitHub Desktop.
How Haskell Compose works
λ> (\x -> Cons' x Nil') <$> (Just $ Right 5)
Just (Cons' (Right 5) Nil')
-- The whole reason of using Compose is acting as a type constructor, here we ended up making Just and Right part
-- of the Compose structure hence we only 5 is passed to the function (\x -> Cons' x Nil)
λ> (\x -> Cons' x Nil') <$> (Compose $ Just $ Right 5)
Compose (Just (Right (Cons' 5 Nil')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment