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

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) -- Russell O'Connor http://r6.ca/ ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.''

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

+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
On Tue, Jul 07, 2009 at 11:33:25PM -0400, roconnor@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@haskell.org http://www.haskell.org/mailman/listinfo/libraries

On Wed, 8 Jul 2009, Edward Kmett wrote:
+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
I was looking for this in your lib, but I didn't find it. Anyhow, I'm also in favour of generalizing Endo. I was being conservitive with my initial proposal. Would we still have to pick a new name and then type Endo a = NewEndoName (->) a ?
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@haskell.org http://www.haskell.org/mailman/listinfo/libraries
-- Russell O'Connor http://r6.ca/ ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.''

Yeah, it would probably have to have a new name because it does have a different kind than the existing Endo. GEndo was the best I could come up with that didn't sound verbose (GeneralizedEndo, CategoricalEndo) or like it was naming the wrong thing (EndoCategory). I'm not wedded to the name by any means. Note: a type synonym,
type Endo = GEndo (->)
like you mentioned would work, but has the downside that it may require
clients that provided instances for Endo to add TypeSynonymInstances where
they previously hadn't and I'm not sure how folks would feel about that.
-Edward Kmett
On Wed, Jul 8, 2009 at 2:05 PM,
On Wed, 8 Jul 2009, Edward Kmett wrote:
+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
I was looking for this in your lib, but I didn't find it.
Anyhow, I'm also in favour of generalizing Endo. I was being conservitive with my initial proposal.
Would we still have to pick a new name and then
type Endo a = NewEndoName (->) a
?
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@haskell.org http://www.haskell.org/mailman/listinfo/libraries
-- Russell O'Connor http://r6.ca/ ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.''
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

Edward Kmett wrote:
Yeah, it would probably have to have a new name because it does have a different kind than the existing Endo. GEndo was the best I could come up with that didn't sound verbose (GeneralizedEndo, CategoricalEndo) or like it was naming the wrong thing (EndoCategory). I'm not wedded to the name by any means.
CatEndo?

On Wed, 8 Jul 2009, Edward Kmett wrote:
Yeah, it would probably have to have a new name because it does have a different kind than the existing Endo. GEndo was the best I could come up with that didn't sound verbose (GeneralizedEndo, CategoricalEndo) or like it was naming the wrong thing (EndoCategory). I'm not wedded to the name by any means.
Note: a type synonym,
type Endo = GEndo (->)
like you mentioned would work, but has the downside that it may require clients that provided instances for Endo to add TypeSynonymInstances where they previously hadn't and I'm not sure how folks would feel about that.
Oh, that is a quite a downside. I wonder if we can get cabal stats on this without difficulty. As for the name, I'd be happy with the EndoMorphism suggestion given. Although it is a bit longish. I'd also be happy with EndoMorph. -- Russell O'Connor http://r6.ca/ ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.''

Not sure I like having the upper case on Morphism in EndoMorphism. Endo is a
prefix, not a word. and and Endomorphism is a bit scary and long.
Isaac's CatEndo suggestion seems relatively innocuous though. (CFunctor,
CMonad, etc. in category-extras Control.Functor.Categorical where all
originally CatFunctor, etc.)
-Edward Kmett
On Wed, Jul 8, 2009 at 4:18 PM,
On Wed, 8 Jul 2009, Edward Kmett wrote:
Yeah, it would probably have to have a new name because it does have a
different kind than the existing Endo. GEndo was the best I could come up with that didn't sound verbose (GeneralizedEndo, CategoricalEndo) or like it was naming the wrong thing (EndoCategory). I'm not wedded to the name by any means.
Note: a type synonym,
type Endo = GEndo (->)
like you mentioned would work, but has the downside that it may require clients that provided instances for Endo to add TypeSynonymInstances where they previously hadn't and I'm not sure how folks would feel about that.
Oh, that is a quite a downside. I wonder if we can get cabal stats on this without difficulty.
As for the name, I'd be happy with the EndoMorphism suggestion given. Although it is a bit longish. I'd also be happy with EndoMorph.
-- Russell O'Connor http://r6.ca/ ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.'' _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
participants (4)
-
Edward Kmett
-
Isaac Dupree
-
roconnor@theorem.ca
-
Ross Paterson