Skip to content

Instantly share code, notes, and snippets.

@nagat01
Last active December 14, 2015 10:16
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 nagat01/82ec16e1009e25f11178 to your computer and use it in GitHub Desktop.
Save nagat01/82ec16e1009e25f11178 to your computer and use it in GitHub Desktop.
-- monad laws
(>>= f) . return = f
(>>= return) = id
(>>= g) . (>>= f) = (>>= ((>>= g) . f))
-- definitions
fmap f = (>>= (return . f))
join = (>>= id)
-- theorem
join . fmap return
= (>>= id) . (>>= (return . return))
= (>>= ((>>= id) . (return . return)))
= (>>= (((>>= id) . return) . return))
= (>>= (id . return))
= (>>= return)
= id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment