Skip to content

Instantly share code, notes, and snippets.

@funrep
Last active December 24, 2015 12:29
Show Gist options
  • Save funrep/6798087 to your computer and use it in GitHub Desktop.
Save funrep/6798087 to your computer and use it in GitHub Desktop.
-- Attempt to implement monads
return' v = \_ -> v
lift a = a ()
bind a f = f $ lift a
inc n = n + 1
mInc a = bind a (\v -> return' $ inc v)
@funrep
Copy link
Author

funrep commented Oct 2, 2013

ghci> lift $ do x <- mInc (return' 5); return' x
6
ghci>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment