OCaml Weekly News
Hello
Here is the latest OCaml Weekly News, for the week of September 16 to 23, 2025.
Table of Contents
- Introduction to the Dune build system, by OCamlPro
- memprof-limits (first official release): Memory limits, allocation limits, and thread cancellation, with interrupt-safe resources
- mlfront-shell - reference implementation of a build system
- Zanuda – OCaml linter experiment
- YOCaml, a framework for static site generator
- Lwt.6.0.0~beta (direct-style, multi-domain parallelism)
- schm-ocaml
- detri cmd
- seven ocaml tutorials
- Ortac/Wrapper: a new plugin for specification driven unit testing
- Other OCaml News
- Old CWN
Introduction to the Dune build system, by OCamlPro
OCamlPro announced
Greetings Cameleers,
We’ve just released a new blog post: OCaml Onboarding: Introduction to the Dune build system
This is a practical, compact guide for those starting their OCaml and Dune journey — or helping others do so. Instead of diving into internals, we focus on what you need to know to get up and running with Dune confidently.
We walk through:
- How Dune thinks about builds and directories
- The role of dune files and static declarations
- The tooling one interacts with day-to-day
The post keeps things hands-on and beginner-focused, with just enough theory to make the practical bits stick. We end by circling back to dune init
— showing how understanding the basics makes the scaffolding tool far more intuitive.
📝 Read it on the OCamlPro Blog
Perfect for sharing with colleagues or newcomers dipping their toes into OCaml and Dune.
As always, feedback welcome! Until next time, — The OCamlPro Team
memprof-limits (first official release): Memory limits, allocation limits, and thread cancellation, with interrupt-safe resources
Guillaume Munch-Maccagnoni announced
I am pleased to announce the version 0.3.0
of the package memprof-limits
. The main contribution of this release is the support for OCaml 5 with multiple parallel domains.
Memprof-limits can henceforth be used to conveniently interrupt (CPU-bound) domains in your parallel computations, using cancellation tokens, with the support of features to ensure interrupt-safety and resource-safety.
As example of uses, plans are underway to use memprof-limits to ensure the resource-safety of user interrupts in the Rocq prover (eliminating a class of bugs) and to add tactics for portable timeouts (that count allocations rather than elapsed time).
- Read more: https://guillaume.munch.name/software/ocaml/memprof-limits.0.3.0/
- Report bugs and suggestions: https://gitlab.com/gadmm/memprof-limits
mlfront-shell - reference implementation of a build system
Archive: https://discuss.ocaml.org/t/ann-mlfront-shell-reference-implementation-of-a-build-system/17186/2
jbeckford announced
There have been many improvements since the last update. Here are some of them:
- The trace store (needed to not rebuild everything from scratch) has been implemented.
- Build file ASTs are parsed, marshalled and put into a key-value directory (which can be shared or cached in CI).
- Build keys are generated and used to protect sharing of the parsed AST.
- A full walkthrough of “building” the 7zip executable from 7zip binary assets (it is more complicated than it sounds) is on the documentation page
- An
–autofix
option to update build files with checksums, and allowing SHA1 checksum for local files (both are for eventual support of Meta’s watchman tool) - A new format for the JSON files (many functions versus one). The old format is deprecated.
- Many many bug fixes, including specification updates.
Zanuda – OCaml linter experiment
Continuing this thread, Kakadu announced
Zanuda 2.0.0 with OCaml 5.3 support have hit opam.
YOCaml, a framework for static site generator
Xavier Van de Woestyne announced
Release 2.5.0
We are delighted to present the new release of YOCaml: 2.5.0
!
As you can see, there have been a few intermediate versions since our last announcement. However, we have reached a new milestone: YOCaml can now be used seamlessly with an Applicative API (instead of the Arrow one), making many tasks much easier to express!
We have also finally taken the time to write a tutorial that explains how to use YOCaml to create a complete blog, step by step, and our goal is to expand it over time to add more and more guides! (The documentation/guide generator (https://github.com/yocaml/yocaml-www is also written in YOCaml and gives an idea of what can be done fairly quickly.)
We look forward to receiving your feedback! YOCaml is a free and collaborative project, so any contributions (including the guide) are more than welcome! We would also be DELIGHTED to see your creations with YOCaml!
Happy Hacking!
Lwt.6.0.0~beta (direct-style, multi-domain parallelism)
Archive: https://discuss.ocaml.org/t/ann-lwt-6-0-0-beta-direct-style-multi-domain-parallelism/17283/1
Raphaël Proust announced
After some feedback and some work, I'm happy to announce the release of lwt.6.0.0~beta00
and lwt_direct.6.0.0~beta00
! (https://github.com/ocaml/opam-repository/pull/28558)
major CHANGES are:
- direct style mode (see alpha release announce): use
await : 'a Lwt.t -> 'a
to transform any promises into a simple value. This allows you to break out of the monad which makes it possible to use libraries previously incompatible with Lwt. - multi-domain support: run separate schedulers in separate domains (some of the more advanced functions on Lwt are now domain-dependent, e.g.,
run_in_main
becomesrun_in_domain
and takes one additional parameter)
Feedback is very welcome. Happy beta-testing and good luck with the parallel-programming!
schm-ocaml
Florent Monnier announced
schm-ocaml provides a scheme-like syntax.
schm3 integrates nicely with the rescript-version that provides the ocaml syntax.
schm4 integrates with one of the later ocaml 4 versions, and tries to be accessible from .c
http://decapode314.free.fr/ocaml2/schm/
There is a tutorial:
http://decapode314.free.fr/ocaml2/schm/schm-tut.html
http://decapode314.free.fr/ocaml2/schm/dl/schm4-0.03.zip
The oo got lost in a computer crash.
So there is no oo.
detri cmd
Florent Monnier announced
There is now a fifth variant for detri:
http://decapode314.free.fr/ocaml/detris.html
This fifth one outputs .html, in-stead of console.
If you took a previous version for the console, it was already something you could do by-yourself easily rewriting the console esc-chars to html, but now there is a ready-made one.
(There is also a small tutorial, but it should be re-written,
http://decapode314.free.fr/ocaml/detri/tut/detri-tut.html
)
seven ocaml tutorials
Florent Monnier announced
You will find seven new ocaml-tutorials on this page that I wrote recently:
http://decapode314.free.fr/ocaml2/blog/
It was not writen with a chat-bot, but you will maybe notice a difference in the style of writing, since I’m using a chat-bot.
Ortac/Wrapper: a new plugin for specification driven unit testing
Charlène_Gros announced
Hello everyone,
We, at Tarides, are excited to announce the release of a new plugin for ortac
: Ortac/Wrapper!
This plugin is part of the Gospel project, a contract-based behavioural specification language for OCaml. ortac
is a tool that converts an OCaml module interface with Gospel specifications into code to check those specifications. There are various ways to check specifications, all provided by plugins, and this post announces the new plugin: Ortac/Wrapper!
This plugin is designed to generate a wrapped module that exposes the same interface as the original module but instruments all function calls with assertions corresponding to the Gospel specifications. The main objective is to assist with unit testing. You provide the Gospel specification for your file, and Ortac will instrument it. When you run the unit tests on the wrapped version, if a specification is violated, Ortac will crash with an explicit error, telling you which portion of your code is incorrect and which specifications were violated.
This work has been started by Clément Pascutto during his PhD at LMF and Tarides https://theses.hal.science/tel-04696708v1.
I continued his work to support some Gospel features such as the old
operator and models.
Installation
To install the Wrapper plugin, use the following command:
opam install ortac-wrapper
This will install the following OPAM packages:
ortac-core.opam
which provides theortac
command-line tool and the core functionalities used by all plugins,ortac-runtime.opam
which provides the support library for the code generated by the Wrapper Ortac plugin,ortac-wrapper.opam
which provides the Wrapper plugin for theortac
command-line tool.
- To automatically generate dune files
If you need dune rules to integrate Ortac into your project, you can install the Dune plugin:
opam install ortac-dune
This will install the following OPAM packages:ortac-core.opam
which provides theortac
command-line tool and the core functionalities used by all plugins,ortac-dune.opam
which provides the Dune plugin for theortac
command-line tool.
Try it!
Let’s dive into a mini tutorial to see how the Ortac/Wrapper plugin can be used to enhance your unit testing with Gospel specifications. We’ll walk through creating a simple polymorphic container type with limited capacity and see how to specify and test its behavior using Gospel.
- 1- Define the type and models
First, we define a polymorphic container type
'a t
with Gospel specifications. This type will have a fixed capacity and a mutable list of contents.type 'a t (*@ model capacity: int mutable model contents: 'a list with t invariant t.capacity > 0 invariant List.length t.contents <= t.capacity *)
Here, we define two models:
capacity
: Represents the fixed size of the container.contents
: Represents the mutable list of elements currently stored in the container.
The invariants ensure that the capacity is always positive and that the contents list never exceeds the declared capacity.
- 2- Specify function behavior
Next, we specify the behavior of functions that manipulate the type
'a t
. We’ll define acreate
function to initialize the container and anadd
function to insert elements into the container.val create: int -> 'a t (*@ t = create c requires c > 0 ensures t.capacity = c ensures t.contents = [] *) val add: 'a t -> 'a -> unit (*@ add t x modifies t.contents ensures t.contents = x :: (old t.contents) *)
Here the functions
create
andadd
are specified in Gospel.- The
create
function requires the capacityc
to be strictly positive and ensures that the model of the new container has the specified capacity and an empty list of contents. - The
add
function modifies the contents of the container and ensures that the new elementx
is added to the list of contents.
- The
- 3- Define projection functions
To validate these specifications at runtime, you need to provide projection functions that link OCaml values to their Gospel models. Projection functions can be defined in two ways.
- Using the same name as the model.
- Using a different name, annotated with the attribute
@@projection_for
and the name of its Gospel model.
For our example, we define the projection functions as follows.
val capacity : 'a t -> int val to_list : 'a t -> 'a list [@@projection_for contents]
Where we encounter the two types of naming.
- The
capacity
function directly corresponds to thecapacity
model. - The
to_seq
function is explicitly declared as the projection for thecontents
model using the@@projection_for
attribute.
These projection functions are mandatory for the Wrapper plugin to instrument the specifications. If any projection function is missing, nothing will be generated and an error will be printed.
- 4- Generate the wrapped version
Once you have both of the interface file annotated with Gospel and your implementation, you can start the generation. If you have installed the
ortac-dune
package (which is recommended), you need to add the following in the dune file where you want to put the tests.(rule (alias runtest) (mode promote) (action (with-stdout-to dune.wrapper.inc (setenv ORTAC_ONLY_PLUGIN dune-rules (run ortac dune wrapper <path to lib/lib.mli>)))))
This will generate an additional Dune file called
dune.wrapper.inc
that you will need to include once created:(include dune.wrapper.inc)
. Also, add the name of the wrapped module to thelibraries
stanza of the test folder. - 5- Add unit tests
In order to test the
Lib
module, we can now simply write a program using the wrapped version. No need to specify the expected behaviour as the instrumentation will take care of that.For example, if you run the following program:
open Lib_wrapped let () = let q = create 3 in add q 1; let q2 = create (-1) in add q2 1; ()
You will obtain the following result:
File "lib.mli", line 8, characters 0-175: Runtime error in function ~create' - the pre-condition `c > 0' was violated. Fatal error: exception Ortac_runtime.Error(_)
This process helps ensure that your code adheres to the specified behavior, making your unit tests more robust and informative.
Feel free to report
For more information here is the link of the dedicated README. If you encounter any bugs or misunderstandings, please feel free to report them as an issue on GitHub.
We hope this plugin will be useful to you and look forward to your feedback!
Acknowledgments
This work is partly founded by the ANR grant ANR-22-CE48-0013.
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.