[Haskell-cafe] From monads to monoids in a small category

Alexander Solla alex.solla at gmail.com
Wed Sep 5 01:21:23 CEST 2012


On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona <agocorona at gmail.com>wrote:

> "Monads are monoids in the category of endofunctors"
>
> This Monoid instance for the endofunctors of the set of all  elements
> of (m a)   typematch in Haskell with FlexibleInstances:
>
> instance Monad m => Monoid  (a -> m a) where
>    mappend = (>=>)   -- kleisly operator
>    mempty  = return
>

The objects of a Kliesli category for a monad m aren't endofunctors.  You
want something like:

instance Monad m => Monoid (m a -> m (m a)) where ...

/These/ are endofunctors, in virtue of join transforming an m (m a) into an
(m a).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120904/4b825385/attachment.htm>


More information about the Haskell-Cafe mailing list