
Joachim Durchholz wrote:
Nope, monoid is a special case of monad (the case where all input and output types are the same). (BTW monoid is associativity + neutral element. Not 100% sure whether monad's "return" qualifies as a neutral element, and my monoid-equals-monotyped-monad claim above may fall down if it is not.
For every monad M, the type M () is a monoid, with mempty = return () x <> y = x >> y Does every monoid arise this way? Yes: Since base-4.9 there is the monad instance Monoid a => Monad ((,) a) and of course a and (a,()) are isomorphic (disregarding bottoms). Also, there is the famous tongue-in-cheek saying "monads are just monoids in the category of endofunctors" which is explained in numerous blog posts and Youtube videos. The monoid M () above has funny properties. Specialize M = [] and obtain the monoid of natural numbers under multiplication. Since (>>) has the more general type Monad m => m a -> m b -> m b We have a monoid action of M () on any type M b. In case of lists, it multiplies elements: [(),()] >> xs doubles the number of every element of the list xs. Olaf

Am 16.07.2018 um 21:48 schrieb Olaf Klinke:
Joachim Durchholz wrote:
Nope, monoid is a special case of monad (the case where all input and output types are the same). (BTW monoid is associativity + neutral element. Not 100% sure whether monad's "return" qualifies as a neutral element, and my monoid-equals-monotyped-monad claim above may fall down if it is not.
For every monad M, the type M () is a monoid,
That doesn't make M a monoid, just its type. Besides, type-level monoids aren't relevant to data-level properties.
Does every monoid arise this way? Yes: Since base-4.9 there is the monad instance Monoid a => Monad ((,) a) and of course a and (a,()) are isomorphic (disregarding bottoms).
An isomorphism does not make it the same, just easily mappable. This is pretty near to hair-splitting, I know. However, from a software design perspective, it's important to keep things separate even if they are easily mappable: temperatures are just floats, it's an incredibly easy mapping - but the code becomes clearer and more maintainable if you keep the Temperature type separate from the Float type. You may even want to forbid multiplying Temperatures (but you want the ability to multiply with a number, and temperature quotients can be useful, too). Not 100% sure how much of this is really applicable.
Also, there is the famous tongue-in-cheek saying "monads are just monoids in the category of endofunctors"
Tongue-in-check does not make it real. And being a monoid in a category does not make it a monoid directly. There's also a final argument: If monad and monoid are really the same, why do mathematicians still keep the separate terminology? Regards, Jo

Le 17/07/2018 à 09:30, Joachim Durchholz a écrit :
being a monoid in a category does not make it a monoid directly.
??? Could you please explain what do you mean by this?
There's also a final argument: If monad and monoid are really the same, why do mathematicians still keep the separate terminology?
I am sure that you see yourself that this is a non-argument. Mathematics is a human activity, not a formal, distilled language. On math.stackexchange.com there is a discussion about "monoid" term history. One user says: Oxford English Dictionary traces monoid in this sense back to Chevalley's Fundamental Concept of Algebra published in 1956. Arthur Mattuck's review of the book in 1957 suggests that this use may be new... Others trace the term to MacLane, or to something which appeared in 1954. So, it was a term which lived separately from monads. == Mathematicians don't quarrel often on terminological issues, unless they have nothing more interesting to do. In the Barr & Wells book monads figure once, just to tell the readers that the term "have also been used in place of “triple”" (Even without the attribution: "Kleisli"...). (And they mention "triads", "fundamental constructions", etc.). In abstract algebra some people say "magma", others: "grupoid" , and --- There is also the inverse phenomenon, the existence of distinct enities with the same name. In Differential geometry, the "pullback" is used differently than in Categories. --- the literature will warn you that grupoid in Category Theory means something different. (Former: a structure with a single binary op; here: a group with partial function replacing the binop). Wikipedia will tell you: "In non-standard analysis, a monad (also called halo) is the set of points infinitesimally close to a given point." Anybody here heard about this?... etc. etc. ... Thanks. Jerzy Karczmarczuk /Caen, France/ --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus
participants (3)
-
Jerzy Karczmarczuk
-
Joachim Durchholz
-
Olaf Klinke