[Haskell-cafe] Map Monoid instance (was commutative monoid?)

wren ng thornton wren at freegeek.org
Sat Jun 25 23:33:30 CEST 2011

On 6/25/11 1:07 PM, Evan Laforge wrote:
> In the
> case of the overriding version, you have to decide on which side to
> merge the new monoid, and on the lifted one the two choices become
> four, since you then have to decide whether the unionWith argument
> should be flipped or not.
> [...]
> So I think the Data.Map choice is reasonable for that reason.  If it
> were lifted, it would have to make a hard-coded decision about the
> "side".  If you have to write your own, that's under your control.

You should pass them through in the same order, to maximize intuitability.
Order swapping can be handled by the Dual newtype.

Live well,

More information about the Haskell-Cafe mailing list