Skip to content

Instantly share code, notes, and snippets.

@dionyziz
Last active April 27, 2019 15:48
Show Gist options
  • Save dionyziz/b49b45cd6c9d6883d720f89d788455e7 to your computer and use it in GitHub Desktop.
Save dionyziz/b49b45cd6c9d6883d720f89d788455e7 to your computer and use it in GitHub Desktop.
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