The function +
is specific to numbers, and moreover, it's only one way to implement Monoid for numbers (*
is equally valid). Similarly, with booleans, it would be equally valid to use &&
and ||
. Using the symbol +
suggests that Monoids are about addition specifically, when really they're just about any associative operation.
It is true that, at least in my experience, one is likely to use mappend
in a fashion resembling addition: concatenating lists or vectors, taking unions of sets or maps, etc, etc. However, the Haskell mindset favors generality and adherence to mathematical principles over (arguably) what is more intuitive. It's certainly reasonable, in my opinion, to think of mappend
as a sort of general addition, and make adjustments in the cases where it isn't.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…