OCaml Weekly News

Previous Week Up Next Week

Hello

Here is the latest OCaml Weekly News, for the week of July 22 to 29, 2025.

Table of Contents

opam 2.4.1

Kate announced

Hi everyone,

Following up the regression reported a couple of days ago affecting some users of pin-depends, we are releasing 2.4.1.

You can read our blog post for relevant links and details.

Try it!

The upgrade instructions are unchanged:

For Unix systems

bash -c "sh <(curl -fsSL https://opam.ocaml.org/install.sh) --version 2.4.1"

or from PowerShell for Windows systems

Invoke-Expression "& { $(Invoke-RestMethod https://opam.ocaml.org/install.ps1) } -Version 2.4.1"

Please report any issues to the bug-tracker.

Happy hacking, <> <> The opam team <> <> :camel:

new tools to keep your projects clean (after AI, or just after yourself)

Thomas Gazagnaire announced

Hi all,

I’ve been experimenting with AI code assistants lately. They’re surprisingly good at generating new code but it's not very good at remembering things: it's like having a steady stream of good interns spending a few months on a project to expand it in one direction and then just disappearing. They produce a lot of code quickly, but that also means they leave a lot behind: unused definitions, inconsistent style, and half-finished refactorings.

Since I couldn’t keep up with reviewing code at the speed these AI assistants generate it, I ended up writing (with their help) a couple of tools to clean things up.

  • prune: removes top-level definitions (values, types, constructors, etc.) that are exposed in .mli files but unused elsewhere in the codebase. It relies on merlin occurrences to find unused identifiers and parses compiler warnings to clean up any breakage (see warning.mli for the full list of handled cases).
  • merlint: runs a set of small static checks using Merlin, ppxlib, and some basic Dune file parsing. It looks for things like code complexity, documentation style, test organisation, etc. This is all very specific to my own style of writing OCaml code but can be made configurable (a bit). See here for the full list of rules (suggestions welcome to add/change some of them).

I originally wrote these to deal with AI-generated code, but they’ve been useful on more conventional OCaml projects too, especially older ones or ones with many contributors or the ones that I wrote a long time ago.

Both are still evolving but they’ve made my workflow a bit smoother already. Feedback and suggestions welcome. I'm still undecided if I should publish those to opam or not.

Thomas

First beta release for OCaml 5.4.0

octachron announced

Two months after the release of the first alpha for OCaml 5.4.0, the release of OCaml 5.4.0 is drawing near.

The internal API of the compiler libraries has been frozen, and most core developer tools support (or will support soon) the new version of the compiler.

We have thus released a first beta version of OCaml 5.4.0 to help you update your softwares and libraries ahead of the release (see below for the installation instructions) [^1].

Compared to the first alpha release, this beta release brings two notable changes. First, this beta partially reverts the changes of symbol names in executable (in order to keep current version of perf working with OCaml executable). Second, this beta fixes a significant performance issue on Apple Silicon macOS.

Beyond these two changes, this first beta release contains a dozen of small bug fixes (from the runtime to the error messages) which is usual for the stage of the release. We are expecting the release candidate to follow this beta release soon in the beginning of August.

The progresses on stabilising the ecosystem are tracked on the opam readiness for 5.4.0 meta-issue.

The full release is expected in the middle of August, see the new prospective calendar for more information.

If you find any bugs, please report them on OCaml's issue tracker.

If you are interested in full list of features and bug fixes of the new OCaml version, the updated change log for OCaml 5.4.0 is available on GitHub.

Happy hacking, Florian Angeletti for the OCaml team

Installation Instructions

The base compiler can be installed as an opam switch with the following commands on opam 2.1 and later:

opam update
opam switch create 5.4.0~beta1

The source code for the beta is also available at these addresses:

  • Fine-Tuned Compiler Configuration

    If you want to tweak the configuration of the compiler, you can switch to the option variant with:

    opam update
    opam switch create <switch_name> ocaml-variants.5.4.0~beta1+options <option_list>
    

    where option_list is a space separated list of ocaml-option-* packages. For instance, for a flambda and no-flat-float-array switch:

    opam switch create 5.4.0~beta1+flambda+nffa ocaml-variants.5.4.0~beta1+options ocaml-option-flambda ocaml-option-no-flat-float-array
    

    All available options can be listed with opam search ocaml-option.

Changes since the first alpha

  • Code generation fixes
    • (breaking change) #13050, #14104, +#14143: Use '$' instead of '.' to separate module names in symbol names on macOS and Windows (including the Cygwin backend). This changes mangling of OCaml identifiers on those operating systems from camlModule.name_NNN to camlModule$name_NNN. Additionally it changes the encoding of special characters from $xx (two hex digits) to $$xx (two dollar signs followed by two hex digits). (Tim McGilchrist, with contributions from Xavier Leroy, reviewed by Xavier Leroy, Miod Vallat, Gabriel Scherer, Nick Barnes and Hugo Heuzard)
    • #14088, #14091: fix non-deterministic code generation in matching.ml (backport of rescript-lang/rescript#7557) (Christiano Calgano, review by Gabriel Scherer and Vincent Laviron)
  • Performance fix
    • #13262, #14074: fix performance issue on Apple Silicon macOS by emitting stlr instead of dmb ishld; str. (KC Sivaramakrishnan, report by François Pottier, analysis by Frédéric Bour, Xavier Leroy, Miod Vallat, Gabriel Scherer and Stephen Dolan, review by Miod Vallat, Vincent Laviron and Xavier Leroy)
  • Standard library fix:
    • (breaking change) #14124: Do not raise Invalid_argument on negative List.{drop,take}. (Daniel Bünzli, review by Gabriel Scherer, Nicolás Ojeda Bär)
  • Runtime fix
    • #14057: Don't update memprof too early at the end of a minor GC. (Nick Barnes, review by Damien Doligez).
    • #13586, #14093: Fix closing an out_channel during flush (Stephen Dolan, report by Jan Midtgaard, investigation by Nick Roberts, review by Antonin Décimo and Miod Vallat)
  • Error message fixes
    • #13956 Fix a regression introduced in #13308 triggering wrong unused warnings. (Ulysse Gérard, review by Florian Angeletti)
    • #14070: also point to label mismatches in error messages for labelled tuples (Florian Angeletti, review by Gabriel Scherer)
    • #14135: Fix a rare internal typechecker error when combining recursive modules, polymorphic fields or methods, and constrained type parameters. (Florian Angeletti, review by Gabriel Scherer)
  • Compilerlibs fixes
    • #14105: Fix a loop in Pprintast that could result in a hang when printing constructor (::) in isolation. (Ulysse Gérard, review by Nicolás Ojeda Bär and Florian Angeletti)
    • #14108: toplevel, fix a typo in directive type mismatch (Florian Angeletti, review by Gabriel Scherer)
    • #14101, #14139: define atomic helper types inside caml/misc.h to improve header compatibility with C++ (Florian Angeletti, report by Kate Deplaix, review by Gabriel Scherer)
  • OCamldoc fix
    • #13896, #14098: ocamldoc, do not wrap module description in a paragraph tag inside the table of modules (Florian Angeletti, report by John Whitington, review by Gabriel Scherer)

    [^1]:More information about the whole release process is now available in the compiler repository

Encoding SAT in OCaml GADTs

Nathan Farlow announced

I had some fun and wrote a post about a SAT -> GADT encoding. Hope you enjoy!

https://farlow.dev/2025/07/27/encoding-sat-in-ocaml-gadts

Other OCaml News

From the ocaml.org blog

Old CWN

If you happen to miss a CWN, you can send me a message and I'll mail it to you, or go take a look at the archive or the RSS feed of the archives.

If you also wish to receive it every week by mail, you may subscribe to the caml-list.