Can we make the Map.Merge API more expressive?
- Dominant language
- Haskell
- Stars
- 355
- Forks
- 194
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 4
Description
I wanted to demonstrate `partitionKeys` recently (https://github.com/haskell/containers/pull/975#issuecomment-2417976839) and realized that the public Map.Merge API is not expressive enough for it.
What I need:
```hs
wm1 :: WhenMissing Pair k a a
wm1 = WhenMissing (\t -> Pair empty t) (\_ x -> Pair Nothing (Just x))
```
Best I can do with the public API:
```hs
wm1 :: WhenMissing Pair k a a
wm1 = traverseMaybeMissing (\_ x -> Pair Nothing (Just x))
```
which is terribly inefficient! (O(1) vs O(n))
Is there a safe way to allow such use cases?
Contributor guide
Research direction
Start by reading the public Map.Merge API, especially WhenMissing and traverseMaybeMissing, and review the partitionKeys example linked in the issue. Determine whether a safe public API can express the shown wm1 behavior without the O(n) traversal; done means the use case is supported with the stated efficiency and its safety is clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100