3 ms·
The "categorical" definition of monads uses return and, instead of bind, join :: m(m a) -> m a You don't need to specify it if you already have bind/>>= and
by mrkgnao 10y ago
The "categorical" definition of monads uses return and, instead of bind,
join :: m(m a) -> m a
You don't need to specify it if you already have bind/>>= and return/pure, since they can be derived from each other.
For instance, purely by "following the types",
f :: a -> m b
fmap f :: m a -> m (m b)
join (fmap f) :: m a -> m b
In other words,
(>>=) :: m a -> (a -> m b) -> m b
ma >>= f = join (fmap f ma)
is a perfectly good definition of bind I you have join.