4 ms·
But "Appendable" is a terrible way to describe what a monoid is. Some of the really cool tricks in the way abstractions in Haskell match mathematical notions co
by cscheid 13y ago
But "Appendable" is a terrible way to describe what a monoid is. Some of the really cool tricks in the way abstractions in Haskell match mathematical notions come from extending the abstractions beyond what you would expect. For example, integers under sum are monoids; naturals under the maximum operation too. And so is the "over" operator from computer graphics. All of these find applicability as general monoids in Haskell, but you'd have a hard time calling them "Appendable". All of these just need a binary operation that's associative and with an identity element.
The same thing happens for functors and monads: their use come from the properties they respect. And if you accept that abstractions will be defined as a set, some operations, and some algebraic laws respected by those operations, well, then, you arrived at abstract algebra, and you might as well use the right terms.
- yohanatan 13y agoI think Combinable is more appropriate as 'append' pertains to only one of many associative binary operations.
- cscheid 13y agoWhat about a group? Is that combinable too? Monoid is short, precise, and googlable. Which also happens to be the case with group, monad, functor, etc. Why invent new vocabulary? Have you noticed how little sense the words "class", "struct", "union", "object" make to someone who hasn't programmed before? It's just that we got used to them.
- lmm 13y agoClasses, unions and objects are all everyday words. I knew them from mathematics and everyday life before I ever used them in programming.
- dllthomas 13y agoAssociativeCombinableWithIdentity ... but I would rather learn what a "monoid" is, than type that out every time.
- axman6 13y agoI've considered Reducable, but I'm not sure that makes much sense either (such as when using a -> a as a monoid, you're not really reducing them). Combinable doesn't work because you're not necessarilly combining the values (Max and 0 for example doesn't really combine, it selects). So it is my conclusion that Monoid is a perfectly good name because that's exactly what a monoid is: something with an associative operator and a value which is the identity for the operator: (&&), True (||), False (+), 0 -- addition (*), 1 -- multiplication (++), [] -- concatenation of lists max, minBound -- maximum (.), id -- function composition and the identity function id x = x there are all monoids, it's such a simple concept that high school students could understand it within 10 minutes, and yet people whinge for calling it what it is. Good programmers are not people who are turned away by terms they don't know this easily.
- yohanatan 13y agoOh yea, I completely agree. There's no reason to be afraid of the terminology. I was just suggesting that Combinable seems a closer fit than Appendable for the general case (although, as you and others have pointed, even it falls short).
- joe_the_user 13y agoJeesh, I have an MA in mathematics but without knowing category theory, it has been opaque to me till just now that the monoids discussed around Haskel are the same beast I briefly dealt with in abstract algebra. Indeed, only by looking up monoid and appendable did this become semi-evident. The Haskellians don't even help you out enough to point towards ordinary abstract but instead send you all the way to category theory with sign-posts along the way. The abstract structure monoid may not really be fully described by appendable but it's a leg-up. The objects in object-orientation get extended by convenience but the term object still helps the learner feel like they've got something concrete.
- dllthomas 13y agoThere are fabulously useful monoids that aren't - in terms of intuition - appending anything at all. For instance, (Sum Integer, Max Integer)
- cscheid 13y agoFirst hit on google for "Haskell Wiki Monoid" was this: http://www.haskell.org/haskellwiki/Monoid http://www.haskell.org/haskellwiki/Monoid Lots of examples there, including a post by Dan Piponi that says, right at the beginning, "In Haskell, a monoid is a type with a rule for how two elements of that type can be combined to make another element of the same type. To be a monoid there also needs to be an element that you can think of as representing 'nothing' in the sense that when it's combined with other elements it leaves the other element unchanged. " I don't know how you can construe that as "The Haskellians don't even help you out enough to point towards ordinary abstract but instead send you all the way to category theory with sign-posts along the way."
- rtfeldman 13y agoNevertheless, if you're a programmer with no particular exposure to that sort of math (which is to say, the overwhelming majority of programmers), saying "this function takes a Monoid" is as useful as saying "this function takes a Foogblort." Saying "this function takes an Appendable" conveys useful information. It's a matter of priorities. If your priority is using the correct mathematical term, you necessarily sacrifice clarity to newcomers. Hence, fewer newcomers. ...of course, not that Haskell as a language has ever strived to attract newcomers!