Answers
- A monad is a type constructor
m
with an instance of theMonad
type class:class Applicative m => Monad m where (>>=) :: m a -> (a -> m b) -> m b return :: a -> m a return = pure (>>) :: m a -> m b -> m b p >> q = p *> q
It is subject to three laws:
return x >>= f = f x p >>= return = p (p >>= q) >>= r = p >>= (\x -> q x >>= r)
Effect |
Monad |
Primitive Operations |
No effect, pure |
|
- |
Failure |
|
- |
Exceptions, errors |
|
|
State |
...