3 ms·
Check yourself before you try to say that "appendable" is an inappropriate name for Monoid. http://hackage.haskell.org/package/base-4.6.0.1/docs/Data-Monoid.ht
by gohrt 13y ago
Check yourself before you try to say that "appendable" is an inappropriate name for Monoid.
http://hackage.haskell.org/package/base-4.6.0.1/docs/Data-Monoid.html http://hackage.haskell.org/package/base-4.6.0.1/docs/Data-Mo...
Methods
mempty
mappend
mconcat
Haskell people like their mathy terms. Mathy terms aren't universally unambigious ("group"? "ring"? "field"?), but they are mostly unambiguous within math. Haskell people tend to pretend Haskell is the same as math, ignoring the programming part of its heritage.
- platz 13y agoprobably because 'mappend' was defined while thinking about usage for lists, but is hardly appropriate for the general case. So, 'Appending' 5 to 3 gives 8; it could be better.
- judk 13y agoThe choices are to either abuse an existing word, or make up new one (possibly a homograph). What is '+' ? Addition? Modular addition? Logical OR? Concatenaton? Sometimes, any of these. There where always be more concepts than distinct labels, since the space of concept is exponential combination (power set) of words.
- platz 13y agoI didn't say it had to be plus. I don't have the perfect answer, but append certainly seems like choosing a specific concept , rather than trying to come up with a more general name.
- tel 13y agoIn practical Haskell people rarely use mappend eschewing it for the more generic (<>) operator. Personally I think it's exactly for the reason stated above—monoid is far more general than "appending". In particular, it's easy to define a reverse monoid for any (non-commutative) monoid such that append becomes prepend. It's easy to construct monoids which have different spacial properties like Diagrams' "stacking" monoid (they have many others, too, see this entire paper http://www.cis.upenn.edu/~byorgey/pub/monoid-pearl.pdf http://www.cis.upenn.edu/~byorgey/pub/monoid-pearl.pdf). It's also easy to construct monoids which don't have any spatial sense at all like set union.
- Peaker 13y agoEveryone hates the name mappend but it's still more commonly used than <> which iirc is relatively recent.
- tel 13y agoFor the record, I agree. There's a lot of older code where `mappend` is used commonly. More accurately, I should have said that (<>) has taken modern coding style by storm.
- asdasf 13y agoI am fully aware of what the typeclass defines. It is an inappropriate name. I don't think there is anyone who likes those names. Everyone uses <> instead of mappened. Append is inappropriate because you do not append lots of monoids, like Product and Sum for example.