Skip to content

Add mapPair #48

@treeowl

Description

@treeowl

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions