From monads to monoids in a small category

"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 article can be found here: http://haskell-web.blogspot.com.es/2012/07/from-monads-to-monoids-in-small.h... I would appreciate some comments.

Your post feels similar to another one posted recently...
http://web.jaguarpaw.co.uk/~tom/blog/2012/09/02/what-is-a-monad-really.html
just fyi, :-),
kris
On Tue, Sep 4, 2012 at 6:39 AM, Alberto G. Corona
"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 article can be found here:
http://haskell-web.blogspot.com.es/2012/07/from-monads-to-monoids-in-small.h...
I would appreciate some comments.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Thanks, Kristopher
2012/9/4 Kristopher Micinski
Your post feels similar to another one posted recently...
http://web.jaguarpaw.co.uk/~tom/blog/2012/09/02/what-is-a-monad-really.html
just fyi, :-),
kris
On Tue, Sep 4, 2012 at 6:39 AM, Alberto G. Corona
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 article can be found here:
http://haskell-web.blogspot.com.es/2012/07/from-monads-to-monoids-in-small.h...
I would appreciate some comments.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona
"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).

On Tue, Sep 4, 2012 at 4:21 PM, Alexander Solla
On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona
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).
Actually, even these aren't endofunctors, for a similar reason that : you "really" want something like instance Monad m => Monoid (m a -> m a) where mempty = id mappend = undefined -- exercise left to the reader (i.e., you want to do plumbing through the Eilenberg-Moore category for a monad, instead of the Kliesli category for a monad -- my last message exposes the kind of plumping you want, but not the right types.)

Alexander,
In my post (excuses for my dyslexia) I try to demonstrate that the
codomain (m a), from the point of view of C. Theory, can be seen as
'a' plus, optionally, some additional element, so a monadic morphism
(a -> m a) is part of a endofunctor in (m a -> m a)
When considering the concept of arrow from category theory, (not the
concept of function), a point in the domain can "send" more than one
arrow to the codomain, while a function do not. I think that this is
the most interesting part of the interpretation, if I´m right.
About this, I found this article revealing:
http://cdsmith.wordpress.com/2012/04/18/why-do-monads-matter/
Therefore, codomains of (a -> m a) which are containers with multiple
a elements can be considered as multi-arrow morphisms from 'a' to 'a'
with the optional addition of some special elements that denote
special conditions.
For example
(a -> [a])
May be considered as the general signature of the morphisms from the
set 'a' to the set ('a' + [])
So a monadic transformation (a -> [a]) can be considered as a point
transformation of a endofunctor within the set (a + []).
Alberto
2012/9/5 Alexander Solla
On Tue, Sep 4, 2012 at 4:21 PM, Alexander Solla
wrote: On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona
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).
Actually, even these aren't endofunctors, for a similar reason that : you "really" want something like
instance Monad m => Monoid (m a -> m a) where mempty = id mappend = undefined -- exercise left to the reader
(i.e., you want to do plumbing through the Eilenberg-Moore category for a monad, instead of the Kliesli category for a monad -- my last message exposes the kind of plumping you want, but not the right types.)

Moreover, `m a` is 'a' plus some terminal element , for example
Nothing, [], Left _ etc, So a morphism (a -> m a) contains all the
morphisms of (m a -> m a).
2012/9/5 Alberto G. Corona
Alexander,
In my post (excuses for my dyslexia) I try to demonstrate that the codomain (m a), from the point of view of C. Theory, can be seen as 'a' plus, optionally, some additional element, so a monadic morphism (a -> m a) is part of a endofunctor in (m a -> m a)
When considering the concept of arrow from category theory, (not the concept of function), a point in the domain can "send" more than one arrow to the codomain, while a function do not. I think that this is the most interesting part of the interpretation, if I´m right.
About this, I found this article revealing:
http://cdsmith.wordpress.com/2012/04/18/why-do-monads-matter/
Therefore, codomains of (a -> m a) which are containers with multiple a elements can be considered as multi-arrow morphisms from 'a' to 'a' with the optional addition of some special elements that denote special conditions.
For example
(a -> [a])
May be considered as the general signature of the morphisms from the set 'a' to the set ('a' + [])
So a monadic transformation (a -> [a]) can be considered as a point transformation of a endofunctor within the set (a + []).
Alberto
2012/9/5 Alexander Solla
: On Tue, Sep 4, 2012 at 4:21 PM, Alexander Solla
wrote: On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona
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).
Actually, even these aren't endofunctors, for a similar reason that : you "really" want something like
instance Monad m => Monoid (m a -> m a) where mempty = id mappend = undefined -- exercise left to the reader
(i.e., you want to do plumbing through the Eilenberg-Moore category for a monad, instead of the Kliesli category for a monad -- my last message exposes the kind of plumping you want, but not the right types.)

On Tue, 4 Sep 2012, Alexander Solla
On Tue, Sep 4, 2012 at 4:21 PM, Alexander Solla
wrote: On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona
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).
Actually, even these aren't endofunctors, for a similar reason that : you "really" want something like
instance Monad m => Monoid (m a -> m a) where mempty = id mappend = undefined -- exercise left to the reader
(i.e., you want to do plumbing through the Eilenberg-Moore category for a monad, instead of the Kliesli category for a monad -- my last message exposes the kind of plumping you want, but not the right types.)
This is not directly responsive to what has been written in this thread, but is a beginner's, likely mistaken, complaint: In many expositions of "monads" and other such Haskelliana, often there is missing a few words of explanation in this style: A monad in category theory is a <here is a pointer or an actual explanation/>. To define the monad M in Haskell, we must pick out a category embedded in some sense in Haskell. A category has objects and morphisms which must obey certain laws. So for M we choose <something/>. Now the <something/> directly above might pick out something which cannot be easily directly described inside the Haskell world, or even in the first layers of the onion of worlds-about-Haskell. For example we might have: The objects of our category are types whose sets of values, always taken without _|_, are finite, or if infinite, come with a partial ordering which is isomorphic to a subset of N^2, with the usual product of N ordering. Note I have no example in mind here, though certainly one can make one up. It is the style I am pointing out. We then must have a paragraph defining, in a similar style, the morphisms, the identity morphisms, and the composition of morphisms of our category, which is "embedded", by means outside of Haskell, into Haskell. Then we must have a paragraph defining the monad itself, so we have our endofunctor T, as Wikipedia calls it in the article on monads (category theory sense), and the two natural transformations \eta and \mu. And then, ah, hmunh, mmh, Oi! again I have failed to look at the standard introductory literature. The missing gentle words of clarification, and thus, encouragement, are at http://www.haskell.org/haskellwiki/Hask and the two notes there pointed to. oo--JS.
participants (4)
-
Alberto G. Corona
-
Alexander Solla
-
Jay Sulzberger
-
Kristopher Micinski