Skip to content

Add an API to merge a Set and Map into a Map#1227

Open
meooow25 wants to merge 1 commit into
haskell:masterfrom
meooow25:map-set-merge
Open

Add an API to merge a Set and Map into a Map#1227
meooow25 wants to merge 1 commit into
haskell:masterfrom
meooow25:map-set-merge

Conversation

@meooow25

Copy link
Copy Markdown
Contributor

This is intended to serve some use cases more efficiently than existing methods, such as partitioning a map according to whether the keys exist in a set.

Similar to Map merging, there are two modules, "Data.Map.Merge.Set.Lazy" and "Data.Map.Merge.Set.Strict" exposing the merge functions and tactics. The WhenMissing tactic for missing maps is simply reused from the Map merging interface. A new WhenMatched tactic is added. A new WhenMissingSet tactic is also added, and I chose to added the "Set" suffix to distinguish it from the existing map tactic. Similarly, the functions that create WhenMissingSet tactics are suffixed with "MissingSet".

Closes #1208

This is intended to serve some use cases more efficiently than existing
methods, such as partitioning a map according to whether the keys exist
in a set.

Similar to Map merging, there are two modules, "Data.Map.Merge.Set.Lazy"
and "Data.Map.Merge.Set.Strict" exposing the merge functions and
tactics. The WhenMissing tactic for missing maps is simply reused from
the Map merging interface. A new WhenMatched tactic is added. A new
WhenMissingSet tactic is also added, and I chose to added the "Set"
suffix to distinguish it from the existing map tactic. Similarly,
the functions that create WhenMissingSet tactics are suffixed with
"MissingSet".
@sjakobi

sjakobi commented Jul 22, 2026

Copy link
Copy Markdown
Member

I think this looks pretty neat, but I think there should be an illustrating example somewhere. E.g. something like your partitionKeys from #975 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generalized API to merge Map and Set into a Map

2 participants