OCaml Weekly News
Hello
Here is the latest OCaml Weekly News, for the week of May 20 to 27, 2025.
Table of Contents
- nanoev 0.1
- 15th MirageOS retreat May 13th - 20th
- MlFront_Signify 2.3.1 - OpenBSD-compatible signify
- Opam 103: Bootstrapping a New OCaml Project with opam, by OCamlPro
- Retirement of Multicore CI Pipelines
- Dune 3.19
- Wrote a Record/Replay Debugging tutorial
- A no-maths guide to monads
- macOS Metal Framework bindings for compute applications
- Other OCaml News
- Old CWN
nanoev 0.1
Simon Cruanes announced
Hello,
I'm happy to announce the first release of nanoev, yet another event loop abstraction. My goal with it is to have a narrow-waist interface between event loops (for now, select
and poll
) and various abstractions built directly on top (for now using picos
), without tying the event loop abstraction itself to a particular scheduler. The core interface for the event loop is basically:
type t
val wakeup_from_outside : t -> unit
val step : t -> unit
(** Run one step of the event loop until something happens *)
val close : t -> Unix.file_descr -> unit
(** Close the file descriptor and clean it up *)
val max_fds : t -> int
(** Maximum number of file descriptors that can be observed at once. *)
val on_readable :
t -> Unix.file_descr -> 'a -> 'b -> (closed:bool -> 'a -> 'b -> unit) -> unit
val on_writable :
t -> Unix.file_descr -> 'a -> 'b -> (closed:bool -> 'a -> 'b -> unit) -> unit
val run_after_s : t -> float -> 'a -> 'b -> ('a -> 'b -> unit) -> unit
and nothing else. I've also started experimenting with using it to drive tiny_httpd.
- docs: https://c-cube.github.io/nanoev/
- release link: https://github.com/c-cube/nanoev/releases/tag/v0.1
15th MirageOS retreat May 13th - 20th
Continuing this thread, gasche said
I'm just back from the Mirage retreat, an event where people interested in Mirage meet for one week to work whatever they want. This retreat was organized by Hannes Mehnert as all past retreats, in Marrakech. Hannes ( @hannes ) asked participants to write a blog post to spread the word – hence this post.
a Mirage retreat, in general
The retreat is unlike most other professional events that I attend, typically academic conferences. We are hosted in a place that is otherwise used as a hostel within the medina, the old city centre of Marrakech. Bed comfort is minimal (a room of six people, two of them snoring), but there are people on-site who prepare food and the food is great. There is very little structure for the day: we had a meeting every morning after breakfast to mention what we had done the day before, and talk sessions in the evening (typically one or two talks for around 40 minutes).
The participants come in all shapes, some are regular contributors to the Mirage ecosystem and some (like me) know very little about Mirage. Some (like me) are very familar with OCaml and others know little about the language. Some people know about networking, security, system administration, communication protocols. The lack of structure encourages people to wander around, for example sitting alongside someone doing something specific and precise, to try something you and learn along. Last time I ended up writing bits of a network driver in OCaml, despite knowing nothing about network drivers; this time I worked on model-based testing of filesystems (see https://discuss.ocaml.org/t/blog-post-using-model-based-testing-on-a-mirage-filesystem-implementation/16666 ), despite knowing nothing about file system implementations.
Morocco has better network connectivity than during my first retreats, but it remains somewhat flaky – and our network-usage habits keep increasing. In particular, I could not attend any online meeting, and this was very nice – just like conferences, it is liberating to be busy for one week uninterrupted. In the past I managed to adapt to low-network usage fairly well. This time I noticed that I depend on github a lot, and I don't know how to have a good offline or network-restricted experience, to do code-reviews in particular. I wish offline version-controlled tools for code-review and bugtracking were more widely employed.
Overall I find this organization excellent: participants get a place and time to learn from each other. I think it could potentially be used for other topics. For example people mentioned that it could be interesting to have a retreat focused on documentation in the OCaml ecosystem, and I find the idea interesting.
(The rest of this post is basically a narrated version of my work log for the week; please feel free to just skip it.)
My OCaml-focused work
One of my projects for the week was to take the time to review large pull-requests on the OCaml compiler that I wouldn't dare attacking usually, because my agenda is perpetually full of other things. I did a first round of review on structured diagnostics, and additional reads through most of the modular explicits pull request (PR). In particular I wrote a small manual section for modular explicits, submitted as a separate PR. I hope to have moved from "it would be nice if these were reviewed someday" to a more short-term phase where I try to get these past the finish line before moving to other topics – but we never know.
I also went through the lists of PRs I had been assigned to, sometimes a while ago. (OCaml triagers assign PRs to each other to keep track of them and try to bring them to a decision, but in practice we often forget to do this and they linger around.) This was fairly effective and my stack of assigned PRs has been about cut in half:
- reviewed and merged:
- closed:
- immediacy computation revamp (@ccasin) #11841
- adopted and merged:
- adopted but not yet merged
A few of those PRs I "adopted", that is, I took control of the PR as the submitter would to rebase the PR and resubmit. In some cases this was mostly to apply my own review comments (sometimes someone else's), the change were minor and I could merge quickly. In some cases the changes were more invasive, and I would ask for another review. In one case I got stuck and wasn't sure how to rebase, so I asked the original author.
"Adopting" PRs in this way is a new process to me, I generally try to guide the authors through making all the changes themselves. I wanted to go through my stack faster, and in some cases I knew that the authors were unresponsive and unavailable to make those changes. I found it fun, but it is probably best reserved to this situation where authors are unavailable.
Side errands
I worked on a race between domain-termination and compaction: #14025. I decided to try to make Dune more pleasant for building the OCaml compiler, and sent a draft/RFC PR at dune#11819. I heard a remark that it's painful not to be able to use lazy thunks anymore for library initialization code (lazy thunks are not concurrency-safe in OCaml 5); I tried to think about why this is hard to fall asleep again after a snoring attack, and ended up writing #14043 instead. I motivated myself into asking for volunteers to review the Relocatable Compiler work.
I also participated as a speaker to two talk sessions in the evening. I did a short demo of Monolith and model-based testing in general – that was before we decided to use it on a Mirage filesystem. I talked about the OCaml Software Foundation and recent discussions around improving the security of the OCaml ecosystem.
MlFront_Signify 2.3.1 - OpenBSD-compatible signify
jbeckford announced
I am pleased to announce the new package MlFront_Signify
is available in opam.
signify
was created by OpenBSD for maintainers to sign distributions and for users to verify those distributions. That is described in signify: Securing OpenBSD From Us To You and the signify manpage.
MlFront_Signify
is compatible with signify
. The C code comes from firmware update code for the embedded Linux router distribution OpenWrt (much easier to build using OCaml tools compared to OpenBSD code). The executable mlfront-signify
has most of the same CLI options as OpenBSD signify
and includes the same trivial tests as signify
, but on Unix you should just use your package manager's signify
. The main contribution of MlFront_Signify
is the OCaml library that is documented at:
I used it with https://discuss.ocaml.org/t/ann-combining-llvm-mc-lld-precompiled-c-and-bytecode/16675?u=jbeckford to perform auto-upgrades. A few MlFront packages participate:
MlFront_Signify
to verify a potential upgradeMlFront_ZipFile
to unpack a verified upgradeMlFront_Cache
to provide an immutable store where multiple versions can co-exist
In particular, the SHA256.sig
file in the file listing https://github.com/diskuv/dkcoder/releases/tag/2.3.202505202143 was created using MlFront_Signify
with the SHA256
checksum file as input. That serves the same purpose as https://cdn.openbsd.org/pub/OpenBSD/snapshots/arm64/SHA256.sig.
MlFront_ZipFile has an important bugfix so please upgrade it to 2.3.1 as well.
Thanks to the Mirage project where I use its mirage-crypto-rng
secure random generator!
Enjoy.
Opam 103: Bootstrapping a New OCaml Project with opam, by OCamlPro
OCamlPro announced
Greetings Cameleers,
We’re back with a new installment in our opam deep-dives
series!
Opam 103: Bootstrapping a New OCaml Project with opam
This time, we’re taking a step back to focus on a beginner-friendly guide to setting up a toy OCaml project with opam
, dune
, cmdliner
, and alcotest
.
This article is aimed at newer members of the ecosystem who may be wondering:
- How do I structure an OCaml project from scratch?
- How to best use opam in my dev workflow?
- How do I write a minimal
.opam
file? - What about a fully fledged one?
We walk through the opam
rationale and offer guidance for building your first opam-compliant package — the kind you can confidently pin and use locally before getting to publishing it.
As always, we hope this piece serves as a helpful reference for those onboarding into the opam
and the OCaml ecosystem and getting their first taste of the tooling.
:link: Check out the other opam deep-dives
articles on https://ocamlpro.com/blog/
Feel free to share feedback or thoughts right here in this thread!
Thank you all for your time, and until next time, The OCamlPro Team
Retirement of Multicore CI Pipelines
Mark Elvers announced
We believe that the two OCurrent pipelines setup for testing OCaml multicore have now served their purpose and will be retired.
Please let me know if you still feel these have value.
Dune 3.19
Etienne Marais announced
The Dune team is happy to announce the release of dune 3.19.0
:smile:
This release contains some important bug fixes along with some improvements for the foreign_library
stanza. It introduces support for concurrent builds through the RPC server.
If you encounter a problem with this release, you can report it on the ocaml/dune repository.
Changelog
- Fixed
- Fixed a bug that was causing cram tests attached to multiple aliases to be run multiple times. (#11547, @Alizter)
- Fix: pass pkg-config (extra) args in all pkgconfig invocations. A missing –personality flag would result in pkgconf not finding libraries in some contexts. (#11619, @MisterDA)
- Fix: Evaluate
enabled_if
when computing the stubs for stanzas such asforeign_library
(#11707, @Alizter, @rgrinberg) - Fix $ dune describe pp for libraries in the presence of
(include_subdirs unqualified)
(#11729, fixes #10999, @rgrinberg) - Fix
$ dune subst
in sub directories of a git repository (#11760, fixes #11045, @Richard-Degenne) - Fix a crash involving
Path.drop_prefix
when using Melange on Windows (#11767, @nojb)
- Added
- Added detection and warning for common typos in package dependency constraints (#11600, fixes #11575, @kemsguy7)
- Added
(extra_objects)
field to(foreign_library)
stanza with(:include)
support. (#11683, @Alizter)
- Changed
- Allow build RPC messages to be handled by dune's RPC server in eager watch mode (#11622, @gridbugs)
- Allow concurrent build with RPC server (#11712, @gridbugs)
Wrote a Record/Replay Debugging tutorial
Sid Kshatriya announced
I've written a tutorial on Record/Replay debugging. If you're interested in reverse debugging please check it out here.
You can do Record/Replay style debugging of your ocamlc.opt
compiled executables. You will be able to place breakpoints on all symbols exposed by the ocaml.opt
compiler – this includes C functions + OCaml functions from your OCaml program and do things like reverse-continue.
For more context please see an announcement I made a couple of months ago: https://discuss.ocaml.org/t/ann-a-tool-to-reverse-debug-ocaml-other-binary-runs/16366/1
(What's new in this new discuss.ocaml.org post is to give focus to the tutorial I've very recently written)
How can rr
/ Software Counters mode rr
help me in OCaml if I'm not interested in gdb style debugging the OCaml executables ?
There are some other useful things that rr
can do for OCaml-ers.
Here is one: Let's say you want to know what programs have been executed when you compile a ocaml program via dune.
$ dune init project hello_world $ cd hello_world/ $ rr record -W -- dune b rr: Saving execution to trace directory `/home/sidk/.local/share/rr/dune-5'.
Now run rr ps
. You will get the exact invocations of all the programs that dune build
triggered ! This takes you all the way down to showing you ld
and ar
invocations !
Very useful when you want to know what happened in the whole process tree.
editor’s note: please follow the post link to see this big terminal output.
A no-maths guide to monads
Raphaël Proust announced
Prompted by someone complaining online about Haskell documentation, I wrote a zero-maths guide to monads (in OCaml, but it applies somewhat more broadly, it's just OCaml has nice binding opearators):
https://raphael-proust.gitlab.io/code/no-maths-guide-to-monads.html
macOS Metal Framework bindings for compute applications
Archive: https://discuss.ocaml.org/t/ann-macos-metal-framework-bindings-for-compute-applications/16713/1
Lukasz Stafiniak announced
Hi!
I'm happy to announce the metal
package with bindings to the Metal framework, with a relatively broad coverage except it does not cover anything graphics or UI related.
- Hosted on GitHub: lukstafi/ocaml-metal: OCaml bindings to Apple Metal for general compute applications
- API documentation: Metal (metal.Metal)
- Released to the repository: metal 0.1.0 (latest) · OCaml Package
- Example usage: ocannl/arrayjit/lib/metal_backend.ml at master · ahrefs/ocannl
Enjoy!
P.S. Disclaimer: code contains AI slop (and likely also my own errors). It's my first major employment of / "collaboration" with Large Language Models and I leaned into accepting choices made by the models.
Other OCaml News
From the ocaml.org blog
Here are links from many OCaml blogs aggregated at 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.