Skip to content

Replace core dependency with base + stdio - #1642

Closed
hhugo wants to merge 1 commit into
stan-dev:masterfrom
hhugo:remove-core-dependency
Closed

Replace core dependency with base + stdio#1642
hhugo wants to merge 1 commit into
stan-dev:masterfrom
hhugo:remove-core-dependency

Conversation

@hhugo

@hhugo hhugo commented Jul 10, 2026

Copy link
Copy Markdown

Summary

Removes the dependency on Jane Street's core, replacing it with the much lighter base + stdio (+ sexplib0). This shrinks the dependency footprint and build time, which is particularly relevant for the js_of_ocaml (stancjs) build.

  • Dependencies: corebase, stdio, sexplib0. The ppx_jane bundle is replaced with only the rewriters actually used: ppx_base, ppx_pipebang, ppx_sexp_message, ppx_sexp_value, ppx_expect, ppx_inline_test.
  • Mechanical changes: open Base instead of open Core; I/O goes through Stdio; stdlib modules that Base deprecates (Format, Obj, Scanf, Marshal, …) are qualified with Stdlib.
  • Core-only APIs replaced:
    • String.{Map,Set,Table,Hash_set} → Base's comparator-passing style (Map.M(String).t, Set.of_list (module String), Hashtbl.create (module String), …)
    • Expr.Typed's Map/Set submodules (previously from Core.Comparable.S, which Base does not provide) are now small explicit submodules exposing exactly the operations used.
    • Map.Make_using_comparator, Set.of_map_keys, fst3 → Base equivalents.
  • New module Common.Poly_containers: Base's Set.Poly/Map.Poly lack sexp converters, so this provides sexp_of_t for both in Core's exact output format — which is why no expect-test output changed.
  • The Generated_signatures code generator now emits Base.Hashtbl instead of Core.String.Table.

Notes for reviewers

  • ppx_jane silently included ppx_pipebang (rewrites x |> f to f x at parse time), and the codebase depends on it: e.g. |> UnsizedType.UArray (constructor after pipe) and several places where record/constructor disambiguation only typechecks with the pipe inlined. It is kept as an explicit dependency.
  • Two tiny semantic substitutions: elt ** 2.elt *. elt (Base makes ** integer exponentiation) and Operator.of_string_opt builds its Sexp.Atom directly instead of going through the deprecated Sexp.of_string.

Testing

  • dune build @all clean
  • dune runtest (unit expect tests + integration cram suite): all pass without a single expected-output change
  • dune build @runjstest (stancjs under node): passes
  • Smoke-tested the stanc binary end-to-end on an integration model

🤖 Generated with Claude Code

Core was only used for its container/comparator layer and a handful of
convenience modules, all of which exist in the much lighter base (plus
stdio for I/O). This drops the compiler's dependency footprint
considerably, notably for the js_of_ocaml build.

- Depend on base, stdio, and sexplib0 instead of core; replace the
  ppx_jane bundle with the individual rewriters actually used
  (ppx_base, ppx_pipebang, ppx_sexp_message, ppx_sexp_value,
  ppx_expect, ppx_inline_test). ppx_pipebang is load-bearing: the code
  relies on `x |> Constructor` and on pipe-inlined type disambiguation.
- open Base instead of Core; route I/O through Stdio and qualify
  stdlib modules Base deprecates (Format, Obj, Scanf, Marshal, ...).
- Replace Core-only APIs: String.{Map,Set,Table,Hash_set} by Base's
  comparator-passing style, Comparable.S submodules on Expr.Typed by
  explicit Set/Map submodules, Map.Make_using_comparator,
  Set.of_map_keys and fst3 by Base equivalents.
- Add Common.Poly_containers providing sexp_of_t for Set.Poly and
  Map.Poly in Core's exact output format, so no expect test changes.
- Emit Base.Hashtbl instead of Core.String.Table in the generated
  Generated_signatures module.

No behavioral changes: all unit, integration, and stancjs tests pass
unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@WardBrian

Copy link
Copy Markdown
Member

Thanks @hhugo. I ended up going with a similar solution in #1643, but one that touches fewer files in the process. Helping trim down the list of what was actually needed (especially on the ppx side) was a huge assist

@WardBrian WardBrian closed this Jul 10, 2026
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.

2 participants