Skip to content

Instantly share code, notes, and snippets.

@deech
Created July 2, 2016 17:52
Show Gist options
  • Save deech/55df1c168eb5222740fb87b743df7e9a to your computer and use it in GitHub Desktop.
Save deech/55df1c168eb5222740fb87b743df7e9a to your computer and use it in GitHub Desktop.
liftM2 equivalent
monadic = do
x <- [0,1]
y <- [0,2]
return (x + y)
applicative = (+) <$> [0,1] <*> [0,2]
comprehension = [(x + y) | x <- [0,1], y <- [0,2] ]
main = do
print monadic
print applicative
print comprehension
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment