Skip to content

Instantly share code, notes, and snippets.

@5outh
Last active December 10, 2015 06:08
Show Gist options
  • Save 5outh/4392149 to your computer and use it in GitHub Desktop.
Save 5outh/4392149 to your computer and use it in GitHub Desktop.
data Identity a = Identity a deriving Show
instance Monad Identity where
return = Identity
(Identity a) >>= f = f a
m1 = Identity 3
addThree x = return $ x+3
bindExample1 = m1 >>= addThree
m2 = Identity "salami"
getLength x = return $ length x
bindExample2 = m2 >>= getLength
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment