Skip to content

Add fromSetMaybe and fromSetMaybeA for maps - #1234

Merged
meooow25 merged 1 commit into
haskell:masterfrom
meooow25:from-set-maybe
Aug 12, 2026
Merged

Add fromSetMaybe and fromSetMaybeA for maps#1234
meooow25 merged 1 commit into
haskell:masterfrom
meooow25:from-set-maybe

Conversation

@meooow25

Copy link
Copy Markdown
Contributor

These are like the existing fromSet and fromSetA, but allow dropping
some keys from the input set. These functions will also be used by the
in-progress Map-Set merge API.

Also adjust fromSet and fromSetA docs to make it consistent with the new
functions.

Closes #1232

@meooow25

Copy link
Copy Markdown
Contributor Author

Pulling g out of buildTree and inlining it seems to have improved the performance of fromSetA. I made the change to only share the code with fromSetMaybe, so this is a nice surprise.

Name                     Time - - - - - - - -    Allocated - - - - -
                              A       B     %         A       B     %
Lazy.fromSetA inner      863 μs  753 μs  -12%    2.4 MB  1.9 MB  -21%
Lazy.fromSetA outer      678 μs  578 μs  -14%    1.9 MB  1.4 MB  -26%
Strict.fromSetA inner    1.1 ms  774 μs  -26%    3.1 MB  2.1 MB  -31%
Strict.fromSetA outer    706 μs  477 μs  -32%    2.0 MB  1.0 MB  -49%
fromSet                  555 μs  560 μs   +0%    1.4 MB  1.4 MB   +0%

These are like the existing fromSet and fromSetA, but allow dropping
some keys from the input set. These functions will also be used by the
in-progress Map-Set merge API (haskell#1227).

Also adjust fromSet and fromSetA docs to make it consistent with the new
functions.
@meooow25
meooow25 merged commit 8db95bb into haskell:master Aug 12, 2026
19 checks passed
@meooow25
meooow25 deleted the from-set-maybe branch August 12, 2026 23:21
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.

Add Map.fromSetMaybe and Map.fromSetMaybeA

1 participant