[Haskell-cafe] Where do trivial functions on the usual containers live?

jack at jackkelly.name jack at jackkelly.name
Mon Dec 21 10:50:12 UTC 2020


December 21, 2020 8:19 PM, "Olaf Klinke" <olf at aatal-apotheke.de> wrote:

> 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


More information about the Haskell-Cafe mailing list