3 ms·
A Monad is pretty simple. class Monad m where return :: a -> m a (>>=) :: m a -> (a -> m b) -> m b and the left-neutral/right-neutral/associativity
by Peaker 15y ago
A Monad is pretty simple.
class Monad m where
return :: a -> m a
(>>=) :: m a -> (a -> m b) -> m b
and the left-neutral/right-neutral/associativity laws:
x >>= return = x
return x >>= f = f x
x >>= (\v -> y v >>= z) = (x >>= \v -> y v) >>= z
Last law can be expressed more easily if you define:
(f >=> g) x = f x >>= g
Then you can say:
(f >=> g) >=> h = f >=> (g >=> h)
How complex is that?