<br><br><div class="gmail_quote">On Tue, Sep 4, 2012 at 4:21 PM, Alexander Solla <span dir="ltr">&lt;<a href="mailto:alex.solla@gmail.com" target="_blank">alex.solla@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><br><div class="gmail_quote"><div class="im">On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona <span dir="ltr">&lt;<a href="mailto:agocorona@gmail.com" target="_blank">agocorona@gmail.com</a>&gt;</span> wrote:<br></div>
<div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
&quot;Monads are monoids in the category of endofunctors&quot;<br>
<br>
This Monoid instance for the endofunctors of the set of all  elements<br>
of (m a)   typematch in Haskell with FlexibleInstances:<br>
<br>
instance Monad m =&gt; Monoid  (a -&gt; m a) where<br>
   mappend = (&gt;=&gt;)   -- kleisly operator<br>
   mempty  = return<br></blockquote><div><br></div></div><div>The objects of a Kliesli category for a monad m aren&#39;t endofunctors.  You want something like:</div><div><br></div><div>instance Monad m =&gt; Monoid (m a -&gt; m (m a)) where ...</div>

<div><br></div><div>/These/ are endofunctors, in virtue of join transforming an m (m a) into an (m a).</div></div></blockquote><div><br></div><div>Actually, even these aren&#39;t endofunctors, for a similar reason that :  you &quot;really&quot; want something like</div>
<div><br></div><div>instance Monad m =&gt; Monoid (m a -&gt; m a) where</div><div>    mempty = id</div><div>    mappend = undefined -- exercise left to the reader</div><div><br></div><div>(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.)</div>
</div>