OCaml Weekly News

Previous Week Up Next Week


Here is the latest OCaml Weekly News, for the week of October 02 to 09, 2018.

Table of Contents

OCaml 4.07.1 released

Damien Doligez announced

We have the pleasure of celebrating the anniversary of Sputnik-1 by announcing the release of OCaml version 4.07.1.
This is a bug-fix release, see the list of changes below.

It is (or soon will be) available as a set of OPAM switches, and as a source download here:

Happy hacking,

– Damien Doligez for the OCaml team.

OCaml 4.07.1 (4 October 2018)

  • Bug fixes:
    • MPR#7815, GPR#1896: major GC crash with first-fit policy (Stephen Dolan and Damien Doligez, report by Joris Giovannangeli)
    • * MPR#7818, GPR#2051: Remove local aliases in functor argument types, to prevent the aliasing of their target. (Jacques Garrigue, report by mandrykin, review by Leo White)
    • MPR#7820, GPR#1897: Fix Array.of_seq. This function used to apply a circular permutation of one cell to the right on the sequence. (Thierry Martinez, review by Nicolás Ojeda Bär)
    • MPR#7821, GPR#1908: make sure that the compilation of extension constructors doesn't cause the compiler to load more cmi files (Jérémie Dimino)
    • MPR#7824, GPR#1914: subtype_row: filter out absent fields when row is closed (Leo White and Thomas Refis, report by talex, review by Jacques Garrigue)
    • GPR#1915: rec_check.ml is too permissive for certain class declarations. (Alban Reynaud with Gabriel Scherer, review by Jeremy Yallop)
    • MPR#7833, MPR#7835, MPR#7822, GPR#1997: Track newtype level again (Leo White, reports by Jerome Simeon, Thomas Refis and Florian Angeletti, review by Jacques Garrigue)
    • MPR#7838: -principal causes assertion failure in type checker (Jacques Garrigue, report by Markus Mottl, review by Thomas Refis)

ppx_yojson: a ppx extension for Yojson literals and patterns

Nathan Rebours announced

I'm happy to announce the release of ppx_yojson a rewriter for all of you out there working with Yojson. Version 0.1.0 provides an extension to write Yojson literal expressions in a more concise and readable way.

As an example, you can write:

let json = [%yojson {some_string = "string"; some_list = [1; 2; 3]}]

instead of:

let json =
    [ ("some_string", `String "string")
    ; ("some_list", `List [`Int 1; `Int 2; `Int 3])

It's available on github and opam. There's more to come soon, including extensions for patterns and antiquotations. You can see the full list of features goals for the 1.0.0 here.

Releases: ppx_deriving_cmdliner, Genspio, Febusy

Sebastien Mondet announced

Hi, this week I cleaned-up and released 3 packages:

→ Genspio 0.0.2

Genspio is a typed EDSL used to generate shell scripts and commands from OCaml.

The idea is to build values of type 'a Genspio.EDSL.t with the combinators in the Genspio.EDSL module, and compile them to POSIX shell scripts (or one-liners) with functions from Genspio.Compile.

See Genspio's documentation root at https://smondet.gitlab.io/genspio-doc/.

New in 0.0.2:

  • Now, the default EDSL module “hides” the distinction between C-Strings and byte-arrays from the user. The distinction was introduced in the second version 0.0.1, cf. discussion in my OCaml 2017 talk.
  • The lower-level API is still there in the module EDSL_v0.
  • There is a new compiler (EDSL.Compile.Slow_flow) which is still just a compiler to POSIX shell scripts, but it uses (many) temporary files to overall simplify the generated code. The goal is to bypass bugs in shells that cannot really handle complex POSIX expressions (one example of which is the quite old version of bash shipped with Mac OSX).
  • Lots of documentation work, including improvements to the js_of_ocaml toplevel-website.
  • A new biggish example: src/examples/service_composer.ml which is a code generator for the “COSC” project (Github: smondet/cosc), a family of scripts which manage long-running processes in a GNU-Screen session (a bit in the style of docker-compose).
  • Also a lot of test hacking, including vm_tester.ml which generates Qemu-based testing setups (e.g. a build of Darwin 8.0 to test very old OSX environments).

(release PR: ocaml/opam-repository#12738)

→ Febusy 0.0.0

Febusy is a monadic-ish library to build dependency graphs between effectful computations while keeping track of their products, a.k.a. “build artifacts.”

One uses the module Febusy.Edsl to construct a direct acyclic graph of build artifacts and then the function Febusy.Edsl.Make_unix.run to “run” the incremental build. For now, the builds run sequentially but the build-artifacts are still properly kept track of between runs with “state” files.

Version 0.0.0 should be considered “alpha-preview stuff.”

(release PR: ocaml/opam-repository#12747)

→ ppx_deriving_cmdliner 0.4.1

The PPX ppx_deriving_cmdliner makes it easy to get a nice command line interface without really knowing much about Cmdliner's API.

It is a ppx_deriving plugin that generates a Cmdliner 'a Term for a given record type.

This release does not add any new feature, only build improvements (recent versions of OCaml, dune-based build, …).

See https://github.com/hammerlab/ppx_deriving_cmdliner.

(release PR: ocaml/opam-repository#12732)

BER MetaOCaml N107, for OCaml 4.07.1

Oleg announced

BER MetaOCaml N107 is a strict superset of OCaml 4.07.1 for ``writing programs that generate programs''. BER MetaOCaml adds to OCaml the type of code values (denoting ``program code'', or future-stage computations), and two basic constructs to build them: quoting and splicing. The generated code can be printed, stored in a file – or compiled and linked-back to the running program, thus implementing run-time code optimization. A well-typed BER MetaOCaml program generates only well-scoped and well-typed programs: The generated code shall compile without type errors. Staging-annotation-free BER MetaOCaml is identical to OCaml; BER MetaOCaml can link to any OCaml-compiled library (and vice versa); findlib and other tools can be used with BER MetaOCaml as they are, in their binary form.

BER MetaOCaml N107 is a superset of the just released OCaml 4.07.1. It also has a number of small improvements: better error messages, no longer needing parentheses when putting a sequence of statements in brackets, more convenient genlet, etc. It also has two notable additions: explicit lifting and new offshoring.

Explicit lifting is the explicit conversion of a value to the code, which, when compiled and run, (re-)produces that value. BER N107 supports explicit lifting of base-type values and lists, options, and, notably, arrays of liftable values. Explicit lifting is described in Section 3.2.1 of the MetaOCaml book.

The generated code, if simple enough, can be `offshored' – converted to the intermediate, imperative language which may then be transcribed to C, OpenCL, LLVM, etc. When generating computational kernels, the code is supposed to be simple enough, so it runs fast. One test case in MetaOCaml distribution shows how can one go about converting the intermediate code to C. Offshoring thus lets us treat a subset of OCaml as a new notation (syntax) for C.

BER MetaOCaml N107 should be available though OPAM, hopefully soon. In the meanwhile, it is available as a set of patches to the OCaml 4.07.1 distribution.
See the INSTALL document in that archive. You need the source distribution of OCaml 4.07.1.

For more explanations, please see
as well as ChangeLog and NOTES.txt in the BER MetaOCaml distribution.

How to write a simple socket-based web client (for Docker)

njb asked and Christophe replied

> I’m trying to create a simple client for Docker

You may be interested by the docker-api package (a new version should be released soon). You are welcome to submit PRs to add functions you care about.

Ocaml Github Pull Requests

Gabriel Scherer and the editor compiled this list

Here is a sneak peek at some potential future features of the Ocaml compiler, discussed by their implementers in these Github Pull Requests.


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 online.