OCaml Weekly News

Previous Week Up Next Week


Here is the latest OCaml Weekly News, for the week of June 04 to 11, 2024.

Table of Contents

Providing Opam system dependancies with Nix

Ryan announced

I've opened a PR with input from @dra27 and @avsm adding support for Nix depexts (system dependencies) to Opam.

Opam supports system dependencies for other platforms by invoking the system package manager, e.g. apt-get install .... However Nix is a bit different, as in general installing a package to your system doesn't create the development environment required to use it; it will only add executables to your $PATH. To find, for example, objects files, outside of a Nix derivation you can use nix-shell and it's descendant nix develop. E.g.:

$ nix-shell -p gmp
-rpath /nix/store/20g5iw2r512gnfrdr4imp2y940v3vlif-shell/lib  -L/nix/store/rx6nkd40819acppajq29g1hxa4d9r35f-gmp-with-cxx-6.3.0/lib -L/nix/store/rx6nkd40819acppajq29g1hxa4d9r35f-gmp-with-cxx-6.3.0/lib

We support Nix depexts with Opam in a similar way. A Nix derivation is build with the desired packages as inputs, and the resulting environment is output as a file in the Opam switch in a format that Opam can parse. This nix.env file is a symlink into the Nix store, so acts as a garbage collection root – packages won't be removed from the store while this file exists. Opam outputs these environment variables on an invocation of opam env.

This fixes issues such as https://discuss.ocaml.org/t/opam-and-nixos-is-there-an-alternative-to-nix-shell/13726.

While the primary use case is on NixOS, this depext mechanism could be used on other platforms to provide a consistent experience including other Linux distributions, BSDs, (and possibly even windows in the future).

Nixpkgs typically only packages one version of a package at a time, but I'm working on versioned depexts with previous version of Nixpkgs as outlined here.

I'm keen to get people's opinions and perspective on this!

ppx_deriving.6.0.2 and ppx_deriving_yojson.3.8.0

Nathan Rebours announced

I am happy to announce the release of ppx_deriving.6.0.2 and ppx_deriving_yojson.3.8.0, the first release of those packages in years!

The main feature here is the port of ppx_deriving's standard derivers ([@@deriving show, make, ord, eq, ...]) and ppx_deriving_yojson to ppxlib's Deriving api. There are no changes to how you'd use those derivers but many benefits:

  • Better performances and better integration with other ppx-es as the code is now generated as part of ppxlib's driver main AST rewriting phase rather than in a separate, dedicated phase.
  • They can now be used with [@@deriving_inline]
  • None of them will break the location invariant required by merlin anymore, fixing a long lasting bug and providing a much better user experience.

You can find the full release notes for ppx_deriving here and for ppx_deriving_yojson here.

I'd like to thank @sim642 for all their work on the ppxlib ports and their patience, and all our other contributors.

I'd also like to thank the OCaml Software Foundation who has been funding my work on those releases.

Effective ML Through Merlin's Destruct Command

Xavier Van de Woestyne announced

I'm very pleased to present you an article with a collection of small illustrations and examples of how to use the destruct command to generate patterns in the presence of pattern matches.

The command has been present in Merlin for several years (and accessible via OCaml-LSP) but, as the various changelogs relating to Merlin mention, we have spent some time polishing it and adapting it to the evolutions of OCaml, making it more stable (essentially in the presence of punning) and taking into account the changes made to the representation of functions (and their parameters).

The aim of the article is to show how the destruct command works in a number of very concrete cases, and ends with an example (a little artificial for the purposes of the article and for teaching purposes) which shows how to use destruct interactively.

Can't wait to hear your feedback! Happy reading!

OCaml Windows Working Group

Sudha Parimala announced

I’m happy to share that we’re starting a working group for OCaml Windows. This is part of a larger effort, First-class Windows, to enhance the OCaml experience on Windows. Through this effort, we aim to coordinate our collective knowledge to identify high-priority items for First-class Windows.

We've started a mailing list to exchange ideas and would greatly appreciate inputs. You can sign up at – https://groups.google.com/u/0/g/ocaml-windows-wg

While the mailing list is intended to be the primary means of communication, we plan to do a sync meeting once a month, to start with. We plan to do a kick-off meeting early next week. Please fill in this poll if you're interested to join: https://strawpoll.com/polls/PbZqbmkNeyN.

Happy camling :camel:

Flambda2 Ep. 2: Loopifying Tail-Recursive Functions, by OCamlPro

OCamlPro announced

Greetings Cameleers,

We would like to share with you our latest Flambda2 Snippet: Flambda2 Ep. 2: Loopifying Tail-Recursive Functions!

Indeed, today's topic is what is called Loopify, one of the many optimisation algorithms found in the Flambda2 optimising compiler project.

We believe Loopify is a nicely representative piece of software for our readers to grasp at the general design and philosophy for all optimisations available in Flambda2! Hopefully, you will do too!

Be sure to check out the Flambda2 Ep.0 article to get all the context for the project itself and the series of blog posts!

In any case, we await your feedback below, and hope that you will enjoy reading this post, and all ensuing ones!

Kind regards, The OCamlPro Team

OCaml Platform Newsletter: March-May 2024

Thibaut Mattio announced

Welcome to the eleventh edition of the OCaml Platform newsletter!

In this March-May 2024 edition, we are excited to bring you the latest on the OCaml Platform, continuing our tradition of highlighting recent developments as seen in previous editions. To understand the direction we're headed, especially regarding development workflows and user experience improvements, check out our roadmap.


  • Explorations on Dune package management have reached a Minimal-Viable-Product (MVP) stage: a version of Dune that can build non-trivial projects like OCaml.org and Bonsai. With a working MVP, the team is shifting their focus to putting Dune package management in the hands of the community. To that end, we have started the Dune Developer Preview Program, where we will test Dune package management with users and refine the user experience in preparation for a final release.
  • The opam team released a second beta of opam 2.2, and with it, opened the final PR to add support for Windows OCaml to the opam-repository. Once the PR is merged, opam 2.2 will be usable with the upstream opam-repository on Windows, paving the way for a third beta very soon, and a Release Candidate next.
  • The odoc team has finalized the initial design for Odoc 3.0 and opened several RFCs to gather community input. We've implemented a new Odoc driver that follows the Odoc 3.0 design and have already started prototyping key parts of the design.
  • Merlin's project-wide references query is getting very close to release. The necessary compiler PR has been merged and included in OCaml 5.2, and the Dune rules PR has been merged and included in Dune 3.16. The next steps are to merge the PR in Merlin itself and the small patch in OCaml LSP.
  • The set of standard derivers shipped with ppx_deriving.std (i.e. [@@deriving show, make, ord, eq, ...]) as well as ppx_deriving_yojson are now directly written against Ppxlib's API. That impacts developers in two ways. First, it allows you to enjoy reliable editor features in projects with those derivers (Ppxlib preserves Merlin's location invariants). Second, you can avoid a hard dependency on those derivers by using Ppxlib's deriving_inline feature on them. Thanks a lot to @sim642 for all your work and very kind patience, @NathanReb for reviewing and release managing, and everyone else involved!


[Dune] Exploring Package Management in Dune (W4)

Contributed by: @rgrinberg (Tarides), @Leonidas-from-XIV (Tarides), @gridbugs (Tarides), @Alizter

Why: Unify OCaml tooling under a single command line for all development workflows. This addresses one of the most important pain points reported by the community.

What: Prototyping the integration of package management into Dune using opam as a library. We're introducing a dune pkg lock command to generate a lock file and enhancing dune build to handle dependencies in the lock file. More details in the Dune RFC.


Over the past three months, significant progress has been made in adding Dune's support for package management. We are thrilled to report that our prototypes have reached a Minimal Viable Product (MVP) stage: an experimental version of Dune package management that can be used to build non-trivial projects, including OCaml.org and Bonsai, which we are using in our tests.

There is still a long way to go, but with this milestone reached, we are now shifting our focus from prototyping to putting the feature in the hands of the community. We are moving to testing the new Dune feature with users, and in particular, now that we have a good understanding of the technical blockers and their workarounds, we will be focusing on validating and refining the developer experience (DX) of Dune package management in preparation for a first release.

To that end, the Dune team has started a Dune Developer Preview Program. We're currently testing the Developer Preview of package management with selected beta testers, and once the biggest issues have been addressed, we'll be opening it to the broader community.


[opam] Native Support for Windows in opam 2.2 (W5)

Contributed by: @rjbou (OCamlPro), @kit-ty-kate (Ahrefs), @dra27 (Tarides), @AltGr (OCamlPro)

Why: Enhance OCaml's viability on Windows by integrating native opam and opam-repository support, fostering a larger community, and more Windows-friendly packages.

What: Releasing opam 2.2 with native Windows support, making the official opam-repository usable on Windows platforms.


The opam team is getting closer to a final release of opam 2.2 with support for Windows. In the past months, we have released a second beta of opam 2.2, addressing a number of issues reported by users on previous releases, including Windows issues.

Excitingly, we also opened the final PR adding support for Windows OCaml to opam-repository. With the PR merged, the opam team is expecting to be able to move to a Release Candidate in June.

Stay tuned for more exciting news and releases in the coming weeks and months!


[​odoc​] Odoc 3.0: Unify OCaml.org and Local Package Documentation (W25)

Contributed by: @jonludlam (Tarides), @julow (Tarides), @panglesd (Tarides), Luke Maurer (Jane Street)

Why: Improving local documentation generation workflow will help package authors write better documentation for their packages, and consolidating the different odoc documentation generators will help make continuous improvements to odoc available to a larger audience.

What: We will create conventions that drivers must follow to ensure that their output will be functional. Once established, we will update the Dune rules to follow these rules, access new odoc features (e.g., source rendering), and provide similar functionalities to docs.ocaml.org (a navigational sidebar, for instance). This will effectively make Dune usable to generate OCaml.org package documentation.


The Odoc team has made significant progress on the upcoming Odoc 3.0. We held productive in-person meetings in Paris to discuss crucial design aspects such as the CLI, source code rendering, and references. These discussions led to the publications of RFCs for the various components of the design specification.

We also started implementing a new Odoc driver that adheres to the new design for testing purposes, and began prototyping several of the new features.

While discussions on the RFCs and specific features are still ongoing, we are very excited to have a solid set of design specifications under community review and to have begun implementing key parts of the new design.


[Merlin] Support for Project-Wide References in Merlin (W19)

Contributed by: @vds (Tarides), @Ekdohibs (OCamlPro), @Octachron (INRIA), @gasche (INRIA), @emillon (Tarides), @rgrinberg (Jane Street), @Julow (Tarides)

Why: Enhance code navigation and refactoring for developers by providing project-wide reference editor features, aligning OCaml with the editor experience found in other languages.

What: Introducing ocamlmerlin server occurrences and LSP textDocument/references support, extending compiler's Shapes for global occurrences and integrating these features in Dune, Merlin, and OCaml LSP.


The past few months have seen fantastic progress on releasing Merlin's project-wide reference query: The compiler PR got merged and included in the now released OCaml 5.2; The Dune rules PR got merged, and with it significant performance improvements have been made on the indexing tool. The final PR in Merlin is open and under review. That PR as well as the small LSP patch to support the feature are about to be merged.

The PR on Merlin also adds support for the feature in the Merlin server plug-in for Emacs. Support for the Merlin server plug-in for Vim has been added separately. All editor plug-ins based on LSP will support the new feature automatically.


  • We followed up on our compiler PR to improve performance for shape aliases weak reduction. It got merged, and made it into OCaml 5.2.0. – ocaml/ocaml#13001
  • We improved the Dune rules that drive the indexer: Simplified the rules, added benchmarks, discussed and improved performance. The PR got merged, and made it into Dune 3.16. - ocaml/dune#10422
  • We polished the indexer ocaml-index: Profiled it and improved its speed by a factor ~2, and improved its CLI.
  • We added a :MerlinOccurrencesProjectWide command to the Vim plug-in based on the Merlin server - ocaml/merlin#1767

OCaml.org Newsletter: May 2024

Sabine Schmaltz announced

Welcome to the May 2024 edition of the OCaml.org newsletter! This update has been compiled by the OCaml.org team. You can find previous updates on Discuss.

Our goal is to make OCaml.org the best resource for anyone who wants to get started and be productive in OCaml. The OCaml.org newsletter provides an update on our progress towards that goal and an overview of the changes we are working on.

We couldn't do it without all the amazing people who help us review, revise, and create better OCaml documentation and work on issues. Your participation enables us to so much more than we could just by ourselves. Thank you!

This newsletter covers:

  • Recipes for the OCaml Cookbook: Help us make the OCaml Cookbook really useful by contributing and reviewing recipes for common tasks!
  • Community & Marketing Pages Rework: We have UI designs for the reworked and new pages of the community section and are starting to implement these. We made progress towards showing videos from the community on the OCaml Planet.
  • General Improvements: As usual, we also worked on general maintenance and improvements, so we're highlighting some of the work that happened below.

Recipes for the OCaml Cookbook

The OCaml Cookbook is a place where OCaml developers share how to solve common tasks using packages from the ecosystem.

A recipe is a code sample and explanations on how to perform a task using a combination of open source libraries.

The Cookbook is live at ocaml.org/cookbook, but there are not a lot of recipes published yet.

When the cookbook was merged, all pull requests to the cookbook branch were automatically closed. We recreated these pull requests and they are ready for review.

Here's how you can help:

  1. Review open pull requests for cookbook recipes!
  2. Contribute new recipes and tasks for the cookbook!

Relevant PRs and Activities:

Community & Marketing Pages Rework

This month, we made some progress towards adding videos from the OCaml community (e.g., from YouTube and watch.ocaml.org) to the OCaml Planet.

Since the size of the OCaml Planet RSS feed grew so large that automation tools (dlvr.it) could no longer process it, we reduced the timeframe for posts to show up in the RSS feed to the last 90 days.

Contributor @ishar19 opened a pull request to add an RSS feed for the Community/Events page. This will allow posting new events to various social media automatically and allow you to subscribe to the Events RSS feed with a RSS reader of your choice.

We have UI designs for the reworked and new pages of the community section and we are opening small issues for contributors to help. :orange_heart:

Relevant PRs and Activities:

Outreachy Internship on Interactive Exercises

On May 27, Divyanka Chaudhari started working with the team, as an Outreachy intern. She's implementing support for running the exercises as a stand-alone project, either in GitHub Codespace, in repl.it, using Jupyter or LearnOcaml.

Relevant PRs and Activities:

## General Improvements and Data Additions

Notable Changes:

  • We restructured the main navigation to have a "Tools" section that holds the OCaml Platform page and the OCaml compiler releases page. This should make the OCaml Platform page easier to find.
  • The Changelog can now be found under "News", from the main navigation. You can also find the OCaml Planet and the Newsletters in this new section.
  • The OCaml Language Manual is now served from OCaml.org, instead of v2.ocaml.org.
  • We added some more links to learning resources to the Resources page at https://ocaml.org/resources.
  • Some documentation updates on "Is OCaml Web Yet?", "Is OCaml GUI Yet?", the ThreadSanitizer tutorial, and the "Functors" tutorial.

Relevant PRs and Activities:

OCaml Windows Working Group

Deep in this thread, Sudha Parimala announced

Thanks to everyone who joined the meeting! Please find the notes here: https://docs.google.com/document/d/1tt-g5f441ClvdGJuK8fvO9Eu2YvWMwDF1wbZ2f8-gsI/edit#heading=h.kwwpagbnenby.

The meeting time this time wasn't US time-zone friendly. We'll try to find a time that works for more people next time.

Registration for Fun OCaml 2024 Opens Shortly

Sabine Schmaltz announced

Registration for Fun OCaml 2024 will open shortly at 17:00 CEST (Central European Summer Time) UTC/GMT +2 hours

Please put yourself on the waiting list if you don't get a ticket immediately, we're doing this in a staggered fashion, unlocking more tickets over the next days! 🧡🐫


opam 2.2.0~beta3

Kate announced

We’re once again very excited to announce this third and final beta for opam 2.2.0.

What’s new in this beta?

  • opam init on Windows enhancements: this beta greatly improves the opam init user experience on Windows, and the number of recognised configurations
  • opam init –cygwin-extra-packages=\<pkgs\>: a new argument to specify additional packages for the internal Cygwin installation
  • Support of user directories containing spaces: opam now redirects the opam root to C:\opamroot\opam-xxx when the opam root contains spaces on Windows
  • UTF-8 paged –help on Windows thanks to cmdliner 1.3.0 and some additional Windows API calls, all the opam --help commands now display a paged view by default similar to Unix-like systems.
  • Many fixes, performance and general improvements

:open_book: You can read our blog post for more information about these changes and more, and for even more details you can take a look at the release note or the changelog.

Windows issues

Configuration of Windows is tricky, so please don’t be too disheartened if things don’t work instantly. If something doesn’t work first time, please do report it, even if you manage to find a way to workaround it. If opam didn’t elegantly tell you what was wrong, then it’s a bug and we’d love to hear about it, rather than ending up with a series of workarounds flying around. It’s no problem at all for us to receive a bug report which turns out to be user error - we’d far rather that than not hear bugs which are opam’s error! 🙀

How to upgrade

  • On Windows

    BEWARE: the command shown below is experimental, use caution and please do report any issues that you are experiencing. If you prefer to not use our experimental script, feel free to get the Windows binary directly from the Release Page and put it in your directory of choice instead.

    Now that the Windows support was merged in opam-repository,

    installing opam is as simple as calling the following command from a PowerShell terminal:

    Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/kit-ty-kate/opam/windows-installer/shell/install.ps1) }"

    opening a new terminal, and a simple opam init will work out-of-the-box.

  • On Unix-like systems

    To upgrade, simply run:

    bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) --version 2.2.0~beta3"

    We’re planning for an opam 2.2.0~rc1 release later next week, so please do report any issue you encounter on our bug-tracker.

Other OCaml News


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.