
21 Dec
2020
21 Dec
'20
5:50 a.m.
December 21, 2020 8:19 PM, "Olaf Klinke"
The usual Semigroup instance of Map k v destroys data upon key collision. For problems like this I have a newtype wrapper
newtype SemiMap f v = SemiMap {getSemiMap :: f v} instance (Semigroup v, Ord k) => Semigroup (SemiMap (Map k) v)
You might like the monoidal-containers package, which newtypes the unordered-containers and containers types to have instances like `instance (Semigroup v, Ord k) => Semigroup (MonoidalMap k v)`. -- Jack