Skip to content

Add Map.merge to FSharp.Core#19994

Open
bbatsov wants to merge 1 commit into
dotnet:mainfrom
bbatsov:feature/map-merge
Open

Add Map.merge to FSharp.Core#19994
bbatsov wants to merge 1 commit into
dotnet:mainfrom
bbatsov:feature/map-merge

Conversation

@bbatsov

@bbatsov bbatsov commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Now that #19265 (print/printn) is in good shape, I went looking for other small, self-contained additions to FSharp.Core I could help with, and landed on suggestion #560: a Map.merge function. It's approved-in-principle and gets asked for fairly regularly, so it felt worth a shot.

Map.merge combines two maps into one. When a key is present in both, a caller-supplied function resolves the two values:

(sample1, sample2) ||> Map.merge (fun _key v1 v2 -> v1 + v2)

I went with the combiner form rather than the plain "last one wins" from the original 2017 proposal, since right-biased merge is just a trivial special case of it (Map.merge (fun _ _ v2 -> v2)).

One caveat: unlike the print/printn ticket, this suggestion never got a detailed RFC, so the exact shape (name, argument order, combiner vs. right-biased) is really my best guess and probably wants a maintainer's eye before it goes any further.

Suggestion: fsharp/fslang-suggestions#560

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/FSharp.Core docs/release-notes/.FSharp.Core/11.0.100.md

@github-actions github-actions Bot added the AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files label Jun 25, 2026
Combines two maps into one, using a caller-supplied function to resolve
the values of keys present in both maps. The right-biased "last one wins"
merge from the original proposal is just a special case of the combiner
form (Map.merge (fun _ _ v2 -> v2)).

Implements fsharp/fslang-suggestions#560.
@bbatsov bbatsov force-pushed the feature/map-merge branch from f0b5cdd to 84c93dd Compare June 25, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant