cheers,

gene ]]>

bind is actually the composition in the Kleisli category of the monad, where the Kleisli category has all the normal objects as its objects but an arrow “f : a -> b” is really of the form “f : a -> m b” in the base category.

]]>(=<<) f = join . fmap f

join = (=<<) id

The real thing that’s interesting about it is that given one of these definitions the other one comes for free. That is, we don’t have to make up any functions, we can just use the id we get for free from being in a category and the fmap we get for free from the monad being a functor.

If you start playing around with the interactions between monads and other functors (e.g. doing a monadic foldr), you’ll see why it’s special to get things for free. For example, there’s no way to write a general monadic fold. In order to write it we’d need to have a new law:

distribute :: (Functor f, Monad m) => f (m a) -> m (f a)

But we can’t define this law in general (i.e. polymorphic in f and m). We can, however, define restricted versions of it for particular pairs of f and m. For some f we can even define it for any m (see the sequence and sequenceA methods of the Traversable class in Data.Traversable).

]]>