
In the Data.Monoid library there is a monoid type instance for Endo a that is described in the following manner:
The monoid of endomorphisms under composition.
I understand how it is a monoid of endofunctions, but am unclear on how it is a monoid of endomorphisms. In the pattern: "forms a monoid of X under Y", X refers to the set and Y to the associative binary operation. So it seems that X in this case is the set of endofunctions. However, it might be possible that the intention was to state that function composition is an endomorphism of the set of endofunctions (Endo a). However even this statement seems difficult to prove in Haskell: opening :: String -> String opening = ("Hello, " ++) closing :: String -> String closing = (++ "!") eo = Endo opening ec = Endo closing appEndo (Endo $ opening <> closing) "Haskell" -- "Hello, HaskellHaskell!" (appEndo eo <> appEndo ec) "Haskell" -- "Hello, HaskellHaskell!" appEndo (eo <> ec) "Haskell -- "Hello, Haskell!" (opening <> closing) "Haskell" -- "Hello, HaskellHaskell!" (opening . closing) "Haskell" -- "Hello, Haskell!" I believe the reason for this behavior is that the fallback for mappend for the general endofunction with type a -> b is found in the Base library as: -- @since 4.9.0.0 instance Semigroup b => Semigroup (a -> b) where f <> g = \x -> f x <> g x

On Sun, Dec 05, 2021 at 02:02:09PM +0000, Adrian via Haskell-Cafe wrote:
In the Data.Monoid library there is a monoid type instance for Endo a that is described in the following manner:
The monoid of endomorphisms under composition.
I understand how it is a monoid of endofunctions, but am unclear on how it is a monoid of endomorphisms.
I'm not sure what you mean. The morphisms in this case are exactly functions. "Endomorphism" and "endofunction" have the same meaning in this context. Tom

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Sunday, December 5th, 2021 at 8:13 AM, Tom Ellis
On Sun, Dec 05, 2021 at 02:02:09PM +0000, Adrian via Haskell-Cafe wrote:
In the Data.Monoid library there is a monoid type instance for Endo
a that is described in the following manner:
The monoid of endomorphisms under composition.
I understand how it is a monoid of endofunctions, but am unclear on
how it is a monoid of endomorphisms.
I'm not sure what you mean. The morphisms in this case are exactly
functions. "Endomorphism" and "endofunction" have the same meaning in
this context.
Tom
According to Algebra [Hungerford 74], an endomorphism is an endofunction that is a homomorphism. A set of endomorphisms is quite distinct from a set of endofunctions in this regard.

On Sun, Dec 05, 2021 at 02:39:01PM +0000, Adrian wrote:
On Sunday, December 5th, 2021 at 8:13 AM, Tom Ellis
wrote: On Sun, Dec 05, 2021 at 02:02:09PM +0000, Adrian via Haskell-Cafe wrote:
In the Data.Monoid library there is a monoid type instance for Endo a that is described in the following manner: > The monoid of endomorphisms under composition. I understand how it is a monoid of endofunctions, but am unclear on how it is a monoid of endomorphisms.
I'm not sure what you mean. The morphisms in this case are exactly functions. "Endomorphism" and "endofunction" have the same meaning in this context.
According to Algebra [Hungerford 74], an endomorphism is an endofunction that is a homomorphism. A set of endomorphisms is quite distinct from a set of endofunctions in this regard.
The "endomorphism" terminology in use in this case comes from category theory rather than algebra narrowly:
An endomorphism of an object x in a category C is a morphism f: x → x
https://ncatlab.org/nlab/show/endomorphism In the case of the Endo documentation, the category under consideration is Hask, the category whose objects are Haskell types and whose morphisms are Haskell functions. Therefore "endofunction" and "endomorphism" refer to the same thing in this context.

On Sun, Dec 05 2021 14:39, Adrian via Haskell-Cafe wrote:
According to Algebra [Hungerford 74], an endomorphism is an endofunction that is a homomorphism. A set of endomorphisms is quite distinct from a set of endofunctions in this regard.
What counts as a "homomorphism" is very dependent on the context that you're in. Here, we are not studying some exotic algebraic structure, but really just functions over a set. In particular, "(homo)morphism" becomes an alias for "function".

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Sunday, December 5th, 2021 at 8:53 AM, Tony Zorman
On Sun, Dec 05 2021 14:39, Adrian via Haskell-Cafe wrote:
According to Algebra [Hungerford 74], an endomorphism is an
endofunction that is a homomorphism. A set of endomorphisms is quite
distinct from a set of endofunctions in this regard.
What counts as a "homomorphism" is very dependent on the context that
you're in. Here, we are not studying some exotic algebraic structure,
but really just functions over a set. In particular, "(homo)morphism"
becomes an alias for "function".
I note that in the paper "Monoid: Theme and Variations" [Yorgey 2012], a monoid homomorphism is defined in a manner consistent with the definitions found in Algebra [Hungerford 74]: A monoid homomorphism is a function from one monoidal type to another which preserves monoid structure; that is, a function f satisfying the laws: f ε = ε f (x <> y) = f x <> f y So again, given that the context is the Data.Monoid library, it seems much more appropriate to say that Endo a forms a monoid of endofunctions under composition. As the examples I presented above show, even stating that function composition is an endomorphism of Endo a (endofunctions) seems incorrect.

On Sun, Dec 05, 2021 at 03:24:13PM +0000, Adrian via Haskell-Cafe wrote:
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Sunday, December 5th, 2021 at 8:53 AM, Tony Zorman
wrote: On Sun, Dec 05 2021 14:39, Adrian via Haskell-Cafe wrote:
According to Algebra [Hungerford 74], an endomorphism is an
endofunction that is a homomorphism. A set of endomorphisms is quite
distinct from a set of endofunctions in this regard.
What counts as a "homomorphism" is very dependent on the context that
you're in. Here, we are not studying some exotic algebraic structure,
but really just functions over a set. In particular, "(homo)morphism"
becomes an alias for "function".
I note that in the paper "Monoid: Theme and Variations" [Yorgey 2012], a monoid homomorphism is defined in a manner consistent with the definitions found in Algebra [Hungerford 74]:
A monoid homomorphism is a function from one monoidal type to another which preserves monoid structure; that is, a function f satisfying the laws:
f ε = ε f (x <> y) = f x <> f y
So again, given that the context is the Data.Monoid library, it seems much more appropriate to say that Endo a forms a monoid of endofunctions under composition.
Yes, I agree that would be a clarifying rewrite, avoiding a clash of terminology.

On Sun, Dec 05 2021 15:24, Adrian wrote:
I note that in the paper "Monoid: Theme and Variations" [Yorgey 2012], a monoid homomorphism is defined in a manner consistent with the definitions found in Algebra [Hungerford 74]:
That is definitely true, but we are not talking about monoid endomorphisms, we are talking about endomorphisms _over a set_ that happen to form a monoid. Endomorphisms over a monoid M certainly need to be compatible with the monoid structure on M, but this is orthogonal to the present question. When `Endo` talks about endomorphisms, it means endomorphisms over the type (think: the set) `a`. More specifically, for any set X we can talk about all functions f: X → X. These are called "endomorphisms" even though they are only functions, because that's exactly what a homomorphism of a set is. The point of `Endo` being in Data.Monoid is that function composition of endomorphisms forms a monoid (with the identity element being the identity morphism) regardless of the underlying structure—be that a set, a monoid, a group, ...
participants (3)
-
Adrian
-
Tom Ellis
-
Tony Zorman