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

Ross Paterson ross at
Wed Jul 8 04:02:55 EDT 2009

On Tue, Jul 07, 2009 at 11:33:25PM -0400, roconnor at 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.

More information about the Libraries mailing list