Last active
April 27, 2019 15:48
-
-
Save dionyziz/b49b45cd6c9d6883d720f89d788455e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Id a = Id a | |
deriving (Show) | |
instance Functor Id where | |
fmap f (Id a) = Id $ f a | |
instance Applicative Id where | |
pure = Id | |
(Id f) <*> (Id a) = Id (f a) | |
instance Monad Id where | |
return = Id | |
(Id a) >>= f = f a | |
a >> f = f | |
thirty :: Id Int | |
thirty = do | |
x <- Id 5 | |
y <- Id 7 | |
return (x * y) | |
main = print thirty |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment