mapEither isn't very general as a multiset operation. It generalizes nicely to
mapPair
:: Ord a
=> (a -> Occur -> ((b, Occur), (c, Occur)))
-> MultiSet a -> (MultiSet b, MultiSet c)
By digging into Data.Map internals, it's also possible to write a very efficient version for when the passed function is strictly increasing (relative to the natural partial ordering of pairs).
mapPairAsc
:: (a -> Occur -> ((b, Occur), (c, Occur)))
-> MultiSet a -> (MultiSet b, MultiSet c)
mapEitherisn't very general as a multiset operation. It generalizes nicely toBy digging into
Data.Mapinternals, it's also possible to write a very efficient version for when the passed function is strictly increasing (relative to the natural partial ordering of pairs).