OCaml Weekly News

Previous Week Up Next Week


Here is the latest OCaml Weekly News, for the week of November 07 to 14, 2023.

Table of Contents

Release of Topiary 0.3.0

Nicolas Jeannerod announced

Hi everyone,

We are pleased to announce the release of Topiary v0.3.0 – Dreamy Dracaena.

What is Topiary?

Topiary is a formatter for OCaml and a universal formatting engine. It is a tool in the Tree-sitter ecosystem, designed for formatter authors and formatter users. Authors can create a formatter without having to write their own engine or even their own parser. Users benefit from uniform code style and the convenience of using a single formatter tool across multiple languages. Topiary is written in Rust and developed by Tweag.

What’s new?

From an OCaml user’s perspective, this release mostly includes the following changes:

There is more but we will point you to the release, the change log or all the changes for those.

How to get it?

You can try Topiary without installing it with our online playground. Topiary is also available via OPAM so you can simply rely on opam install topiary. If you are curious as to how we packaged a Rust project in OPAM, we have just the blog post. Nix users, you can find Topiary in nixpkgs or rely on the flake github:tweag/topiary. Finally, since this version, statically-linked binaries are available for download from the GitHub release.

We hope you like it; do try, report issues, ask for features, or tell us your love!

Cheers, The Topiary team.

blog/announce: https://www.tweag.io/blog/2023-03-09-announcing-topiary/

First release of OCaml bindings to the Polars dataframe library

mt_caret announced

Hi everyone!

I’m excited to share a project I’ve been working on: polars-ocaml, some OCaml bindings to the Polars dataframe library. If you’ve ever wanted to do data science or tabular data processing in OCaml, please consider trying this out!

Polars is a quite performant dataframe library written in Rust, with an API that is built on top of the Apache Arrow format with a focus on performance, utilizing parallelism and SIMD to get pretty big speedups compared to regular records or libraries like pandas.

We’ve ported most of the examples in the Polars user guide to OCaml in the form of expect tests: https://github.com/mt-caret/polars-ocaml/tree/main/guide I encourage folks to take a look if you’re interested in seeing some examples of idiomatic usage of polars-ocaml; I think the labelled arguments and use of GADTs have made the API quite nice to work with!

How to get it

We’ve just released the first version to opam, so you can install it with opam install polars. It also works with OCaml jupyter notebooks via ocaml-jupyter:



If you find any issues or have any questions, feel free to comment or raise an issue on GitHub. While we’ve exposed a fair amount of polars functionality, there’s quite a lot more we haven’t gotten around to, so PRs are very welcome!

How-To: Buck 2 and OCaml - Build system

Continuing this thread, Roland Csaszar announced

Added a chapter on how to generate the Merlin files: Using Buck 2 with OCaml-LSP or Merlin

Release of Moonpool 0.5

Simon Cruanes announced

Dear OCaml enjoyers,

I’m quite giddy at the opportunity to announce the release of Moonpool 0.5. Moonpool is a MIT-licensed thread-pool library for OCaml 5, with an eye towards mixed IO and CPU workloads.

Moonpool’s unique[^1] design allows the creation of multiple thread pools that share an underlying domain pool. Due to how domains work in OCaml 5, there should be at most n domains active at once, where n is roughly the number of cores on the machine. For mixed workloads that rely on threads, this is not really adequate as it means that only n tasks can run or block on IO at the same time. Instead Moonpool permits the creation of many more threads, possibly in independent pools (ie. with independent schedulers), for different workloads.

Moonpool also provides some concurrency primitives such as futures, locks, and a blocking queue.

This release (changelog) has seen a lot of change in Moonpool: there are now two distinct pool implementations that abide by the same Runner interface:

  • “fifo” pool: a simple pool with a single blocking queue for workloads with coarse granularity tasks that value latency (e.g. a web server)
  • “ws” pool: a work-stealing pool for heavy compute workloads that feature a lot of await/fork-join, with a lot of help from Sadiq, KC, and especially Vesa Karvonen (@polytypic) to whom I’m very grateful for his help and explanations.

Documentation can be found here.

[^1]: for now, at least.

Zipc 0.1.0

Daniel Bünzli announced


It’s my pleasure to announce the first release of the Zipc library:

Zipc is an in-memory ZIP archive and deflate compression codec. Other compression formats in ZIP archives can be supported by using third-party libraries.

Zipc has no dependencies and no C code. It is distributed under the ISC license.

This first release benefited from and finishes a generous grant from the OCaml Software Foundation for the years 2022 to 2023. My donators are also paramount to be able to get these things ironed and out for reasonable third-party usage, rather than them remaining private kludges to support urgent needs ;–)

Thank you all for your support.

Homepage: https://erratique.ch/software/zipc

Docs: https://erratique.ch/software/zipc/doc (or odig doc zipc)

Install: opam install zipc (once this [PR] is merged)


New Tutorials on Basics of OCaml

Cuihtlauac Alvarado announced

Dear OCamlers

The OCaml.org team is happy to announce the publication of two new tutorials:

  1. Values and Functions
  2. Basic Data Types and Pattern Matching

These pages teach the basics of OCaml, starting from what is a value and continuing to basic types. Before them, the documentation on OCaml.org assumed a lot more understanding and made it hard for beginners to learn OCaml using OCaml.org. There are more gaps to fill, but alongside the recently published “Get Started” docs (Installing OCaml, A Tour of OCaml and Your First OCaml Program), this will allow people to use OCaml.org to start learning the language.

Unlike “Get Started” documents, these two have a narrower focus:

  • The former is new. It covers values, definitions, functions, environments, scopes, closures, and shadowing.
  • The latter is mostly new. It reuses some of the “Data Types And Matching” materials. But it also replaces it. It covers predefined types, variants, records, and pattern matching.

They form a series. “Values and Functions” goes first, and “Basic Data Types And Pattern Matching” goes after. The only prerequisite is the completion of the “Get Started” series.

We’ve received and included feedback on them when they were pull requests. However, as of any fresh release, there’s room for fixes and improvements. Don’t hesitate to share your opinion, comments or suggestions. Since this is beginner-oriented material, we’d appreciate very much if you find brave enough people to learn OCaml using them and provide a report on how it went.

Hope it helps

cll 0.2.0 - mutable circular/cyclic doubly linked lists

Rob Anderson announced

Hi all,

This is cll, a simple circular linked list implementation designed for O(1) insertion and removal, O(n) traversal, and close to O(1) search using a backing hashtable.

Currently it supports:

  • initialising a circular linked list from a standard list with init
  • traversing through the list using next and prev functions
  • adding and removing elements at the current head using add and pop
  • finding and navigating to elements in the list either by iterating through all elements or looking up elements with the backing hashtable
    • seek to iterate through and perform an O(n) lookup
    • find to perform an O(1) lookup
  • iterate through the full list from the current head and apply a given function to each element with iter
  • output the current circular list as a standard Ocaml list using to_list

I started developing cll after writing circular linked list implementations for a couple of programming puzzles, and decided that writing and publishing a library was a good way for me to continue learning Ocaml.

I have included examples in the Github repo for both of these puzzles: Advent of code 2020 day 23 (crab cups), and the Josephus problem Codewars kata.

Global dead code elimination in js_of_ocaml

Micah Cantor announced

Hi everyone!

We recently merged a large change to js_of_ocaml that implements a new global dead code elimination pass. I wrote the following blog post which explains the impact of this change, why it was necessary, and all the important implementation details:


In a nutshell, this change addresses a long-known limitation of js_of_ocaml to remove unused code from functors (like Map and Set). Previously, even if only one function from these modules was used, all of the function definitions would be included in the JavaScript executable, significantly increasing the output size.

In practice, programs that compile with js_of_ocaml and depend on libraries that expose large functor interfaces (like TyXML, for instance) could see significant decreases in output size. In particular, for a minimal website using tyxml, we saw a decrease by 21kb or 11% of the total JS size. Websites using Map and Set could also see size decreases of up to 10kb for each module.

The new pass is enabled by default, and from our benchmarking, it shouldn’t contribute a significant increase in compile time for most programs (as in, less than 100ms). However, some very large projects (like ocamlc or the OCaml toplevel compiler) could see a compile time increase of 1-5%. If this is significant, the pass can be disabled with --disable globaldeadcode.

Thank you to Tarides for supporting this work through my internship, and in particular to my incredible mentors @vouillon , @otini and @jmid . Also thanks to @hhugo for reviewing and providing feedback on the pull request.


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.