Skip to content

Use the stdlib Map for the compiler's maps - #8790

Draft
cknitt wants to merge 3 commits into
stdlib-setfrom
stdlib-map
Draft

cknitt wants to merge 3 commits into
stdlib-setfrom
stdlib-map

Conversation

@cknitt

@cknitt cknitt commented Oct 10, 2026

Copy link
Copy Markdown
Member

Last of four PRs moving the compiler's own collections onto the OCaml standard library, stacked on #8789. This one covers maps.

Map_ident, Map_int and Map_string are now Map.Make instances with the same comparison functions, including Ext_string.compare (length first) for strings, so iteration order is unchanged. Call sites use the stdlib API and argument order. The ext-only helpers map onto stdlib functions:

  • find_exn → find
  • find_default → find_opt with a default
  • adjust → update
  • disjoint_merge_exn → union with a failing merge
  • to_sorted_array_with_f → bindings
  • compare_key → Ext_string.compare

Ext_map and Map_gen are removed, together with the ounit tests of their helpers. With this PR the compiler has no hand-written ordered or hashed collections left apart from Ordered_hash_map and Hash_set_ident_mask, which have no stdlib equivalent.

Output: byte-identical to #8789 on 628 files (Belt, all of tests/tests/src, and the benchmark stress inputs).

Performance: the whole stack against master measures CPU +0.2% (noise) and allocation +0.6%. The removed maps had a compact leaf node that stdlib Map doesn't have.

🤖 Generated with Claude Code

cknitt and others added 2 commits October 10, 2026 19:01
Map_ident, Map_int and Map_string are Map.Make instances with the same
comparisons; Ext_map and Map_gen are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt added this pull request to stack #8788 October 10, 2026 19:01
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
@pkg-pr-new

pkg-pr-new Bot commented Oct 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8790

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@8790

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8790

@rescript/darwin-x64

npm i https://pkg.pr.new/@rescript/darwin-x64@8790

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8790

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8790

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8790

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8790

commit: 4d1e83e

This branch has not been deployed

No deployments
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.

1 participant