OCaml Weekly News

Previous Week Up Next Week


Here is the latest OCaml Weekly News, for the week of July 25 to August 01, 2023.

Table of Contents

opam 2.2.0 alpha2 release

R. Boujbel announced

On behalf of the opam dev team, I’m happy to announce you the 2nd alpha release of opam 2.2.0.

This alpha introduces a new option to initialise opam on Windows: remove the need of a preexisting Cygwin and propose to install an internal Cygwin install managed by opam.

You’ll find more information in the blog post and a more detailed view in the release note.

Cross-compiling OCaml with GitHub Actions

jbeckford announced

As mentioned in the original post, that was a preview for a few months. Jan 2022 was long ago, and I didn’t get any feedback that anybody was using it.

Regardless, I rolled up the cross-compiling functionality into the dkml-base-compiler package. But a huge dose of caution … cross-compiling is not officially supported by OCaml! And unlike when I originally wrote the post, I now actively use my non-free DkSDK CMake product because, among other things, it wraps dkml-base-compiler cross-compiling into a “normal” IDE push-button experience (in fact, as we speak I’m helping some high schoolers use Android Studio to cross-compile OCaml into their Android Java app). So if you use dkml-base-compiler for its cross-compiling features, make sure you have intermediate-advanced comfort with the OCaml compiler, and be comfortable with getting your own support.

Here is what you’ll need if you (or anyone searching in the future) are that intermediate-advanced compiler user and want to get dkml-base-compiler working in your environment:

All the best!

Release opam-switch-mode 1.7 with Tuareg+Merlin support

Erik Martin-Dorel announced

Emacs: new minor mode for opam users

Dear all,

If you happen to use use several opam switches and Emacs as an IDE: you may be interested in opam-switch-mode (which overlaps tuareg-mode’s M-x tuareg-opam-update-env function but provides several additional features).

To be more precise:

  • this minor mode requires GNU Emacs 25.1 and is available in MELPA, MELPA Stable, NonGNU-devel, NonGNU;
  • it displays the currently chosen switch in the mode-line;
  • it provides an OPSW menu-bar (also working in TTY) and an OPSW mode-bar menu, as well as a ~M-x opam-switch-set-switch~function;
  • all of these allow to select a regular opam switch or a local opam switch;
  • they trigger before/after the opam switch change, the functions registered in the hooks 'opam-switch-before-change-opam-switch-hook and 'opam-switch-change-opam-switch-hook
  • these hooks are internally used by Tuareg, Merlin (or ProofGeneral for Coq) to kill the OCaml toplevel or the Merlin server: so that the next eval or save action uses the appropriate binary from the new switch;
  • and finally, the minor mode stores the initial environment (before the mode is enabled), providing a Reset feature to backtrack to the initially chosen switch.

Here is a screenshot of the opam-switch-mode in GNU Emacs 27.1:


Happy hacking!

dune 3.9.0

Etienne Millon announced

We just released dune 3.9.2. This bugfix-only release contains two platform-specific changes: one fixes the Dune cache on Windows, and the other one completes the fix on Linux when sendfile is not available. This makes Dune available where user directories are encrypted using ecryptfs for example.


  • Disable background digests on Windows. This prevents an issue where unremovable files would make dune crash when the shared cache is enabled. (#8243, fixes #8228, @emillon)
  • Fix permission errors when sendfile is not available (#8234, fixes #8210, @emillon)

DkML 2.0.x Releases

jbeckford announced

DkML 2.0.2

Consider 2.0.2 to be a preview release. The 2.0.2 installers and release notes are here

The major change is there is a standalone “Bytecode Edition” installer:

  • utop, ocamlc, ocamlfind work with base, refl, graphics and sqlite3. (I intend later to add the tsdl related packages)
  • No opam, Visual Studio, Git or MSYS2. That is a fast install (see Answers below).
  • Comes embedded with a bytecode system OCaml compiler and pre-compiled packages (base, etc.)
  • dune works to the extent Dune works with bytecode: you have to set explicit (modes ... byte), and you have to explicitly ask for the bytecode artifacts with dune build x/y/z.bc
  • VS Code works with the OCaml Platform extension (ie. ocamllsp works alongside dune build x/y/z.bc)

If people think they’ll use it, now is the time to say so! I don’t intend to support something very few people will use.


FYI, The “windows 64-bit installer” in this page is a dead link.

Thanks! DkML 2.0.2 should have live links, unlike 2.0.1

do you have a guesstimate on the install time for this bytecode-only base system on standard machines?

The “Bytecode Edition” is under 5 minutes to download (~200MiB), and under 5 minutes to install.

Announcing the ocaml-wasm organisation

Deep in this thread, zapashcanon said

I added a few notes on how to try Wasocaml. Don’t expect everything to work now as this was indeed a quick prototype (more on this below).

The goal of Wasocaml was to convince the Wasm-GC working group of the usefulness of i31ref because we knew it would be needed by OCaml. Without this work they may had been removed from the proposal. We presented the work in January to the working group. In March we also presented this work at the Dagstuhl seminar on the foundations of WebAssemby which was the opportunity to discuss with some active members of the Wasm community such as Andreas Rossberg, Ben Titzer and Conrad Watt. In April, the Guile compiler to Wasm-GC was also presented and it was also using i31ref. Having two languages using i31ref convinced the working group. This is what allows Wasm_of_ocaml to use i31ref today. :slight_smile:

Wasocaml is also the first compiler for a real-world functional languages to Wasm-GC. We developed many strategies for the memory representation of values. For now we only presented two of them (more are coming!) and they should work for other languages/compilers. Wasm_of_ocaml and Guile are using similar techniques to what we presented.

A little bit more about the differences between Wasocaml and Wasm_of_ocaml… First, Wasm_of_ocaml being a tool external to the compiler, it is of course easier to deploy quickly. Wasocaml starts from Flambda and will thus benefit all the optimizations that are missing from the bytecode. Binaryen will be able to recover some performances but it has its limits. Moreover, Wasocaml is going to play nicely with separate compilation. Also, Wasm_of_ocaml is limited in its value representation choice (it must represent blocks as an eqref array) whereas Wasocaml can use more sophisticated representations.

Also note that none of the two are actually usable in a production today. They both depends on many Wasm extenstions (typed function references, GC, tail-call, exception handling, string reference…) that are not yet available in browsers (you can use them in chrome if you turn some experimental flags on).

Alongside all the future works that @lefessan described, I’m also formalizing the compilation of flambda to Wasm-GC with a proper semantics.

On a related note, we indeed implemented Owi, a Wasm interpreter written in OCaml. It was a way to experiment with language extensions. Currently, our main work on the interpreter is to add the possibility to do symbolic execution of Wasm code (aka whitebox fuzzing). This allows to automatically find input values that lead to a crash in the program. The nice thing is that it allows to find bugs in code written in another language and compiled to Wasm (e.g. C).

Brr 0.0.6 and Note 0.0.3

Daniel Bünzli announced

There’s a new release of Brr and Note.

Brr is an ISC licenced toolkit for programming browsers with the js_of_ocaml compiler. Note is an experimental ISC licensed library for functional reactive programming.

If finally got to split away the Note FRP stuff from Brr. The brr package therefore no longer depends on the note package. If you used the brr.note library it now lives in note.brr. Accordingly the toplevel module names were changed from Brr_note* to Note_brr*.

Among other things, the Brr release also brings a revamped Uri module which was a bit broken. Have a look the release notes before upgrading if you are using it. Thanks to Max Lang for noticing and helping to fix that.



A big thanks to my donators.

Hilite 0.3.0

Patrick Ferris announced

Happy to announce a new release of hilite, a small library to perform build-time syntax highlighting of some common (in the OCaml world) programming languages. Hilite performs the syntax highlighting on OCaml.org (see for example https://ocaml.org/docs/lists). It has a useful Hilite.Md.transform function which will rewrite code blocks for you (i.e. transform : Omd.doc -> Omd.doc). I may, in the not too distant future, drop Omd in favour of Cmarkit.

Happy highlighting :camel: :art:

htmlit 0.1.0 – HTML generation combinators for OCaml

Daniel Bünzli announced

I’d like to announce the first release of htmlit (docs):

Htmlit is an OCaml library providing simple but subtle combinators for generating HTML fragments and pages.

Htmlit is distributed under the ISC license. It has no dependencies.

Install: opam install htmlit (once this PR is merged).



A big thanks to my donators.

jumpnbrownweasel asked and Daniel Bünzli replied

How would you compare Htmlit to tyxml,

Htmlit does not try to type your HTML. To get a good compositionality story, it does a few tricks on class and style attribute specifications and supports direct fragment splicing in element childrens.

tyxml tries to type your HTML which I find totally unusable in practice. I tried the tyxml approach during some time in first decade of the century after @thomega came up with the technique twenty years ago.

I moved away from it quite quickly to prefer to treat HTML as an untyped assembly language rather than try to put lipstick on a pig. In my opinion the technique has terrible type and refactoring usability and still doesn’t prevent you of generating invalid HTML (e.g. no guarantee on id uniqueness). Honestly when you are dealing with the web, generating valid HTML is the least of your problem.

what was the motivation for creating Htmlit?

That was a long time ago; the copyright says 2016 but I’m pretty sure I used that in some more primitive form much before. The motivation is in the summary: to have a simple and usable library for generating HTML fragments or pages to send over the wire or store on your file system.

forester 2.2.1 release

Jon Sterling announced

I would like to advertise the release of Forester 2.2.1 on opam, which is an OCaml utility to develop “Forests”, which are densely interlinked mathematical websites / Zettelkästen similar to the Stacks Project or Kerodon. An example of a “Forest” is my own website.

Package: https://opam-5.ocaml.org/packages/forester/

Forester is potentially of technical interest to this community as it makes use of new OCaml 5 features like effect handlers, as well as certain functions from domainslib.

Multicore libraries: new releases

Sudha Parimala announced

Hi everyone! I’m happy to share updates on new releases of multicore libraries. KC’s blog post provides an excellent overview of the big picture and how the developments in the compiler, libraries and tooling fit together.

Saturn and Saturn_lockfree (0.4.0)

I’m delighted to present to my fellow camlers Saturn and Saturn_lockfree, now available in opam-repository. Saturn is the new alter ego of our old friend lockfree. Saturn (and its sub-libraries) subsume lockfree, and aim to be a collection of parallelism-safe data structures for OCaml 5. Saturn_lockfree provides a set of lockfree data structures that are well tested. Furthermore, cache-aligned atomics recently landed on trunk OCaml, which opens up exciting possibilities to explore for lock-free algorithms.

The renaming stems from a desire to expand the scope of the library to be more than just lockfree. Essentially a data-structure can be blocking, lock-free or sometimes partially lock-free ( and not defined in other times). We ran into intriguing questions such as “When is a structure lock-free, really?” in the process of developing them.

Considering the perspective of a user of parallelism-safe data structures, whether they are transitioning their libraries to OCaml 5 or building something from scratch, it’s reasonable to assume that their primary concerns would be the correctness and performance of these structures, rather than the nitty-gritties of progress conditions. These structures are model-checked and have a good set of property based tests. They have some benchmarks with more on the way. Saturn aims to be a collection of reliable and performant parallelism-safe data structures.

Amongst other things, Saturn will host:

The README has comprehensive descriptions for the above-mentioned items (as well as more details coming soon). Here is the changelog.

DSCheck (0.3.0)

DSCheck is an experimental model checker for testing concurrent programs. Concurrency bugs can be notoriously hard to track down. DScheck explores the possible interleavings of concurrent programs, thereby helping us catch potential bugs early on. It manages to do this by a neat combination of exploring branches needs to be explored, and mocking parallelism with effect handlers.

Changelog for the latest release is here. The major improvement this release contains is the Source Sets approach for optimal reduction. This is has hugely reduced the number of branches to explore in the tree of possible interleavings, and thereby improving the performance by a great margin. The next release will hopefully include granular dependency relation for the DPoR algorithm, which further speeds up the dscheck tests by over 5x.

Domainslib (0.5.1)

Domainslib provides easy ways to write nested parallel programs in OCaml 5. Amongst other things, the 0.5.1 release supports domain-local-await (DLA), enabling smooth interoperability with other libraries supporting DLA such as Eio, Kcas, Moonpool and so on. This opens up interesting possibilities to juxtapose domainslib for parallelism and Eio for IO, in the same application. Furthermore, this release includes a parallel_find which helps propagate exceptions.

Eio (0.11.0)

This new release contains feature additions such as extending Eio.Condition, removing deprecated functions and bug fixes. As we’re heading towards a 1.0 release of Eio, we hope to share more frequent updates on Eio.

In tandem, a number of applications are migrating to Eio to exploit OCaml 5 features. You can find many of them at awesome-multicore-ocaml. For folks interested in this, @talex5 and @jonludlam are running a tutorial at ICFP on the same subject.

Happy hacking! :camel:


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 online.