3 ms·
But one of the examples of adding maps would be for it to mean "upsert", rather than "use the monoid for the value types". I think that's still a perfectly good
by oddthink 7y ago
But one of the examples of adding maps would be for it to mean "upsert", rather than "use the monoid for the value types". I think that's still a perfectly good monoid over maps (it's not commutative, but that's not a requirement).
And yes, you can argue that using "+" implies commutative, and I can see that, but I think it's still a plausible meaning in this context.
(I'm probably rabbit-holing here, but it's interesting.)
- noelwelsh 7y agoHow you handle this gets into the details of the programming language used for implementation. The usual implementation technique is type classes, and the issue of having multiple type classes (implementations of, say, monoid) for a given type is known as "type class coherence". In Scala you could just pass a type class instance explicitly. If Haskell you'd have to change the type.