OCaml Weekly News

Previous Week Up Next Week

Hello

Here is the latest OCaml Weekly News, for the week of March 25 to April 01, 2025.

Table of Contents

MlFront_ZipFile - High-level API for zip files

jbeckford announced

I am happy to announce that MlFront_ZipFile.2.3.0, a package that can do basic zip/unzip operations on a zip file, was released today. It is available on opam with opam update and opam install MlFront_ZipFile.

There are other opam packages for zip files, and often those are more appropriate. MlFront_ZipFile is different because:

  • It is very high-level. I wanted an API to unzip and zip, with a simple observer API for unzipping so I could attach @CraigFe's excellent progress bar library.
  • It can unzip 4GB files in a 32-bit OCaml runtime.
  • It has a permissive license.
  • It is not thread-safe (except unzipping).
  • It fully embeds the C code. That means it works on Windows and should work under cross-compilation without needing a non-portable/non-reproducible pkg-config installation.
  • It has a binary mlfront-zip which can do glob-based exclusions (a feature not present in the typical InfoZip /usr/bin/zip that comes with Unix or PowerShell Compress-Archive on Windows). macOS, Windows and Linux have prebuilt binaries.

Here are the relevant links:

Sidenote: The docs won't be available on ocaml.org. Use the doc links above until I figure out a technical solution (very low-priority).

MlFront_Cache - Transient caches + slowly varying data

jbeckford announced

I am happy to announce that MlFront_Cache.2.3.0, a framework for transient caches and slowly varying data, was released today. It is available on opam with opam update and opam install MlFront_Cache.

MlFront_Cache lets you cache files and directories, all backed in a local sqlite3 database. It is a bit esoteric. I use it for:

  1. Transient caches when downloading zip files.
  2. Immutable installs for DkCoder. A related use case is covered in detail in the docs as "Downloading datasets".

Treat this as an alpha release with a somewhat unstable API. In particular, I haven't implemented cache eviction yet.

Here are the relevant links:

Sidenote: The docs won't be available on ocaml.org. Use the doc links above until I figure out a technical solution (very low-priority).

New lesson on polymorphic variants

Jakub Svec announced

Hello,

I wrote a new lesson on polymorphic variants.

You can find it here.

I appreciate any feedback you may have. I expect that if there is interest in including a lesson on polymorphic variants that there will likely be several rounds of refinement.

Sources:

This lesson is about 800 lines long (about 1100 with line length limited to 85 columns). This makes this lesson on the longer side when compared to other lessons on OCaml.org. Therefore, this is the first of 2 lessons on polymorphic variants.

This lesson (lesson 1) introduces the concepts behind polymorphic variants (such as row polymorphism and structural typing), then discusses common syntactic structures of polymorphic variants. It teaches these concepts in a bottom-up direction. It is my subjective belief (held lightly) that introducing polymorphic variants in a top-down direction leads to more complexity and confusion.

Lesson 2, which is forthcoming, introduces common usecases for polymorphic variants through real-world examples.

Any feedback a reviewer is willing to provide is greatly appreciated. The author is particularly interested in ensuring accuracy and validity of examples and consistency in the language with OCaml.org's other materials, but all feedback is welcome.

The OBazl Toolsuite 3.0.0.beta.1

Gregg Reynolds announced

The OBazl Toolsuite 3.0.0.beta.1 is now available.

The OBazl Toolsuite is a collection of rules & tools that support OCaml development using Bazel. To get started:

$ git clone https://github.com/obazl/demo_hello.git
$ cd demo_hello
$ bazel run bin:greetings

See The OBazl Book for more guidance.

Tested on MacOS and Linux (Ubuntu).

This version contains many improvements:

  • Improved toolchain support. Select a compiler by passing e.g. --tc=ocamlc.
  • Seamless opam dependencies. The previous version required a preprocessing step (running bazel run @coswitch); this is no longer necessary.
  • Fine-grained dependencies. Depend directly on any module, whether it is in a library or not, and whether it is namespaced (~~wrapped'') or not.
  • Context-sensitive archiving. Archives are for distribution; internal dependencies do not need them. The ocaml_library rule will only construct an archive on demand. By default, an internal dependency on an ocaml_library target will not request archiving. This can be overridden.
  • Several examples of OBazl extensions: rules_ppx, rules_cppo, rules_ctypes, rules_menhir. These demonstrate the relative ease with which tools can be integrated into the Bazel environment.
  • A new tool, bazel run @obazl//new that generates a project from a template.
  • Direct support for the tools in the standard SDK (ocamldebug, ocamlobjinfo, etc.) and for a subset of the OCaml Platform tools. For example:
    • $ bazel run @opam -- list
    • $ bazel run @ocaml
    • $ bazel run @utop
    • $ bazel run @dbg --@dbg//pgm=src:greetings

OBazl ensures that these commands will be invoked under the correct switch, with correct paths (CAML_LD_LIBRARY_PATH etc.), insulated from environment variables.

Other tools are invoked by passing an option to an ordinary build command. For example:

  • $ bazel build lib/hello:Hello --modinfo # runs ocamlobjinfo on the .cmo/.cmx output
  • $ bazel build lib/hello:Hello --siginfo # runs ocamlobjinfo on the .cmi output
  • $ bazel build lib/hello:libFoo --archinfo # runs ocamlobjinfo on the .cma/.cmxa output
  • $ bazel build lib/hello:Hello --gensig # runs ocamlopt -i on the .ml file to generate inteface code.

The documentation at The OBazl Book has been updated. It remains far from complete but it should be useful. In particular the OBazl Guide and the rules_ocaml Reference Manual.

What's missing?

  • Support for opam publishing. I have successfully published an OBazl (Bazel) project to an opam switch, and used it in a dune-only project, but the code is still under development so I don't have a demo.
  • Support for odoc, ocamlformat, and linting. Currently under development.
  • Windows support. The code is designed for portability but it will probably be a while before I can get to Windows.
  • Automatic generation of BUILD.bazel files. I have a tool for this but it is outdated. Bringing it up-to-date is a high priority.

Support:

Cheers!

Gregg

Dune dev meeting

Etienne Marais announced

Hello :waving_hand: The next Dune Dev Meeting will be on Wednesday, April, 2nd at 9:00 CET. This is going to be a one-hour-long meeting.

Whether you are a maintainer, a regular contributor, a new joiner or just curious, you are welcome to join: these discussions are opened! The goal of these meetings is to provide a place to discuss the ongoing work together and synchronize with the Dune developers :+1:

The agenda is available on the meeting dedicated page. Feel free to add more items in it.

Other OCaml News

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.