3 ms·
It's maybe worth noting that we have a choice of how values are merged on collision. I think it's a monoid only when that choice forms a semigroup. In the cas
by dllthomas 9y ago
It's maybe worth noting that we have a choice of how values are merged on collision. I think it's a monoid only when that choice forms a semigroup.
In the case of configurations, "right bias" (aka Last) is probably a good choice. I don't like that Haskell chose it for the general Map instance.
- whateveracct 9y agoYeah the Map monoid instance is very unfortunate :( When I came from Scala I really missed the one in scalaz (which is as you describe) reducers has a UnionWith newtype which gives you the better Map monoid. But I think it uses a lazy unionWith, which will cause your Map to leak space when used in a foldMap over many elements :(