Adding a newtype EndoCategory to Control.Category (ticket #3362)

Edward Kmett ekmett at gmail.com
Wed Jul 8 09:33:13 EDT 2009


+1 in favor of generalizing Endo in Data.Monoid.

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.

-Edward Kmett

On Wed, Jul 8, 2009 at 4:02 AM, Ross Paterson <ross at soi.city.ac.uk> wrote:

> On Tue, Jul 07, 2009 at 11:33:25PM -0400, roconnor at theorem.ca wrote:
> > I suggest adding a wrapper to make (a x x) a Monoid for any Category a
> > and type x. This would be added to Control.Category.
> >
> > newtype EndoCategory a x = EndoCategory { runEndoCategory :: a x x }
> >
> > instance (Category a) => Monoid (EndoCategory a x) where
> >   mempty = EndoCategory id
> >   mappend (EndoCategory f) (EndoCategory g) = EndoCategory (f . g)
>
> In Data.Monoid there is
>
>  newtype Endo a = Endo { appEndo :: a -> a }
>
>  instance Monoid (Endo a) where
>        mempty = Endo id
>        Endo f `mappend` Endo g = Endo (f . g)
>
> and (->) is an instance of Category, so perhaps we should generalize Endo.
>
> The name EndoCategory seems wrong, as this won't be an instance of
> Category.
> Endomorphism?
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/libraries/attachments/20090708/e0af3787/attachment.html


More information about the Libraries mailing list