+1 in favor of generalizing Endo in Data.Monoid. <br><br>In my monoids library I have a Data.Monoid.Categorical that includes a 'GEndo' generalized endomorphism over an arbitrary category and I would love to be able to remove it.<br>
<br>-Edward Kmett<br><br><div class="gmail_quote">On Wed, Jul 8, 2009 at 4:02 AM, Ross Paterson <span dir="ltr"><<a href="mailto:ross@soi.city.ac.uk">ross@soi.city.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Tue, Jul 07, 2009 at 11:33:25PM -0400, <a href="mailto:roconnor@theorem.ca">roconnor@theorem.ca</a> wrote:<br>
> I suggest adding a wrapper to make (a x x) a Monoid for any Category a<br>
> and type x. This would be added to Control.Category.<br>
><br>
> newtype EndoCategory a x = EndoCategory { runEndoCategory :: a x x }<br>
><br>
> instance (Category a) => Monoid (EndoCategory a x) where<br>
> mempty = EndoCategory id<br>
> mappend (EndoCategory f) (EndoCategory g) = EndoCategory (f . g)<br>
<br>
</div>In Data.Monoid there is<br>
<br>
newtype Endo a = Endo { appEndo :: a -> a }<br>
<br>
instance Monoid (Endo a) where<br>
mempty = Endo id<br>
Endo f `mappend` Endo g = Endo (f . g)<br>
<br>
and (->) is an instance of Category, so perhaps we should generalize Endo.<br>
<br>
The name EndoCategory seems wrong, as this won't be an instance of Category.<br>
Endomorphism?<br>
<div><div></div><div class="h5">_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
</div></div></blockquote></div><br>