ICFP 2024
Jane Street's OCaml Language team brings nine papers and talks to ICFP 2024 and describes its compiler-branch extensions: modal types (modes like local and unique) for Rust-like control over allocation and data-race-free parallelism, and a kind system for unboxed layouts. Examples include a redesigned Bonsai API that uses a local-mode witness and escape analysis to enforce its two-phase graph-building model, mixed blocks for records combining boxed and unboxed fields, ppx_template for stamping out kind/mode-specialized code until real polymorphism lands, and a zero-overhead or_null option type that uses kinds to forbid nesting. The team also released a bleeding-edge opam repo with the extended compiler and its libraries so outsiders can try the features ahead of any upstreaming.
Related posts
- Oxidizing OCaml: Rust-Style Ownership
Jane Street Tech Blog hardMasterJane Street's OCaml extensions add Rust-style ownership through mode axes. A uniqueness axis (unique, exclusive, shared) enables in-place functional updates, type-changing strong updates and safe resource APIs. Borrowing via `&` combines with locality so values can be lent without consuming them. Exclusively mutable fields give mutation without move semantics, and a linearity axis (once vs many) stops closures that capture unique values from being invoked twice, which would otherwise break type safety. Unlike Rust, these modes carry no lifetime variables, so they avoid higher-order polymorphism and don't interfere with type inference.
- Oxidizing OCaml: Locality
Jane Street Tech Blog hardMasterJane Street is extending OCaml with modes, starting with a locality mode that marks values as local (cannot escape their region) or global, so the compiler can stack-allocate short-lived values while keeping garbage collection everywhere else. Locality is inferred automatically and checked by the compiler. An `exclave` keyword lets a function return a local value into its caller's region, and local parameters let APIs like `with_file` guarantee that resources are not used after release. Unlike Rust's lifetime variables, modes are separate from types and do not affect type inference. They are deep and form a sub-mode order (global ≤ local), which forbids heap-to-stack pointers.
- Oxidizing OCaml: Data Race Freedom
Jane Street Tech Blog hardMasterJane Street's OCaml extensions use a new `sync` mode to make data races statically unrepresentable in multicore OCaml 5. Immutable and exclusively mutable values are `sync` and shareable across domains, while ordinary mutable values are `unsync` and confined to one domain. Mode-annotated mutexes give roughly safe-Rust capabilities. Capsules go further: they encapsulate unrestricted shared mutability, such as cyclic mutable structures, behind existentially typed keys, so code can mutate shared-ownership data in parallel without Rust-style fine-grained ownership tracking or unsafe code.
- What the interns have wrought, 2021 edition
Jane Street Tech Blog mediumAdeptJane Street's 2021 dev internship (87 interns across New York, London and Hong Kong) is showcased through three projects. One extended the OCaml syntax extension ppx_typed_fields, which uses GADTs to make record fields first-class values. It now supports parameterized and nested records, and a new typed-variants extension does the same for variant types. A second built filterable cross-day time-series exports of historical atop process data for the CLI and web UI. A third added memoization of intermediate computations to Datafetcher, a Haxl-like OCaml DSL for data-fetching jobs that run in production, test or record mode.
- Writing a DSL for high performance parallel programming in OxCaml
Jane Street Tech Blog hardMasterA Jane Street intern built a JIT compiler for an SPMD-style DSL in OxCaml so SIMD kernels for options pricing and risk checks can be written once as ordinary-looking OxCaml functions instead of architecture-specific C intrinsics. Kernels describe the computation for a single output index, and the compiler generates the loop, which keeps each iteration writing exactly one output and makes vectorization safe. The front end builds a GADT-typed DAG that tracks uniform vs. varying rates and provides three control-flow forms (select, if_, if_var) with different evaluation semantics. The backend uses OxCaml's runtime metaprogramming (quotes and splices) to emit OxCaml code, partially evaluating runtime-known values such as the chosen distance metric away and relying on the OxCaml compiler for further optimization.