Previous week Up Next week


Here is the latest OCaml Weekly News, for the week of May 29 to June 05, 2018.

  1. ATD - static types for json APIs, v1.13.0 | new documentation home
  2. llpp v28
  3. First release of PGX (Pure-OCaml PostgreSQL client)
  4. First release of Crlibm
  5. New version of package lbfgs
  6. First opam release of easy_xlsx
  7. Other OCaml News

ATD - static types for json APIs, v1.13.0 | new documentation home


Martin Jambon announced:
We've made a lot of internal changes to the ATD suite of tools, including
atdgen. Atdgen is a full-featured program that takes type definitions and
derives OCaml parsers and serializers for json. For example,

type hello = {
  greeting : string;
  ?fruit : fruit option;

type fruit = [ Peach | Cherry ]
results in two OCaml functions of the following types:
val hello_of_string : string -> hello
val string_of_hello : greeting:string -> ?fruit:fruit -> unit -> string

The purpose of this announcement is primarily to bring the attention of the
community to the existence of this tool, which most people should be using
instead of straight yojson (the parser and AST-handling library on which atdgen

This is a stable release available from opam, and the changes are mostly
internal. Different tools relying on atd have been consolidated into one repo,
efforts are ongoing to make the codebase more accessible, and [new, exciting
features are being developed](!

$ opam install atdgen

Check out the [documentation's new home](!

Martin, on behalf of the [ATD team](
Shon then said:
The new documentation looks great :slight_smile:

In my scant use of JSON for OCaml stuff so far, I've primarily relied on
`ppx_deriving_yojson`. Are there use cases for which `atdgen` is inherently
better suited, or is it mainly just a matter of methodological preferences
(e.g., of command line tools and separate file formats over inline annotations)?
Martin Jambon replied:
Atdgen is geared toward interoperability between applications.

The main features that distinguish it from its camlp4-based predecessor
[json-static]( and from
[ppx_deriving_yojson]( are:

* The specification of the ATD language is not tied to the OCaml language.
* Generated code is plain text that's easy for the user to inspect.
* Direct parsing/serializing without going through an AST.

Historically, atdgen was created out of a desire to not depend on the "new
camlp4" released around 2007, which suffered many undocumented changes as well
as unsatisfying build-time performance. Atdgen only needed a small fraction of
the features of camlp4 anyway. Atdgen was developed at that time with a focus of
mapping type definitions to various languages.

llpp v28


moosotc announced:
New version of llpp (tagged llipposuction) is now available at:


llpp is a graphical PDF pager, which aims to superficially resemble


videos -
bug tracker -

Changes (relative to v27)

* Removed:
  remnants of Microsoft Windows (Cygwin) support
  some rarely used keyboard shortcuts
  automatic shell completion generators
  vestiges of Make
  altivec memory clearing
  non-persistent bookmarks

* Improved:
  build system
  inotify script (Malte Tammena)
  macOS support

Summary v27..v28
   480	malc
    15	moolc
     2	0xe0f
     2	Malte Tammena
     1	Nicolás Ojeda Bär

Diffstat v27..HEAD
[..snip for brevity..]
74 files changed, 3538 insertions(+), 5063 deletions(-)

First release of PGX (Pure-OCaml PostgreSQL client)


Brendan Long announced:
I'm happy to announce the first release of
[PGX]( on opam. PGX is a pure-OCaml
PostgreSQL client based on PG'Ocaml.

Since the fork, we've made the following improvements:

- More tests ([80%
  coverage]( on the
  latest commit)
  - We designed our tests we [write them
    and then run them against
  - Tests also [run on every commit](
- More consistent use of async API's (we do our best to never use synchronous API's)
- Addition of
  for hopefully easier conversion to and from DB types
- [Safe handling of concurrent
  (not any faster, but they won't crash)
- [Improved interface for prepared
  statements]( to
  [make it harder to use them
- We include Pgx_async, Pgx_lwt, and Pgx_unix (synchronous) so you don't have to
  write your IO module (and possibly get it wrong)
- Probably other things I've forgotten by now

We're still looking for feedback on the API and pull requests are welcome!

First release of Crlibm


Christophe announced:
I am happy to announce the first release of
[crlibm](, a binding to the _proved_
correctly-rounded mathematical library
For most of the usual functions, this library provides 4 versions, one rounded
to the nearest, one rounded up, one rounded down and one rounded towards zero.
Here is an example:
#require "crlibm";;
~/.opam/4.06.1/lib/crlibm: added to search path
~/.opam/4.06.1/lib/crlibm/crlibm.cma: loaded
# pi;;
- : float = 3.14159265358979312
# Crlibm.cos pi;;
- : float = -1.
# Crlibm.Low.cos pi;;
- : float = -1.
# Crlibm.High.cos pi;;
- : float = -0.999999999999999889
# Crlibm.Zero.cos pi;;
- : float = -0.999999999999999889
The project is [hosted on Gihub](

New version of package lbfgs


Christophe announced:
It is my pleasure to announce a new release of
[lbfgs](, a binding to Nocedal's
[implementation]( of
(BFGS) algorithm using a limited amount of computer memory with the possibility
of setting bounds on the variables. The purpose of this algorithm is to solve
large-scale nonlinear optimization problems. Here are some [elementary examples
of use]( I hope
you will find this library useful.

First opam release of easy_xlsx


Brendan Long announced:
I'm pleased to announce the first release of
[easy_xlsx]( and some related
lower-level libraries
to parse the contents of an XLSX file, and
to parse Microsoft's "Open Packaging Specification", which is used by all new
Microsoft Office formats).

See [documentation

The short version is that if you need to read a .xlsx file, you can do:

Easy_xlsx.read_file "example.xlsx"
|> List.iter (fun sheet ->
  printf "Got sheet: %s\n" ( sheet);
  Easy_xlsx.rows sheet
  |> List.iter (fun row ->
    List.iter (function
      | Easy_xlsx.Value.Date d -> (* *)
      | Datetime dt -> (* Ptime.t *)
      | Number n -> (* float *)
      | String s -> (* a string obviously *)
      | Time t -> (* Ptime.time *))))

(There's also a `Easy_xlsx.Value.to_string` if you just want to convert XLSX to CSV)

If you have any XLSX files that don't work right and can make them public,
please open a pull request to add them to the test suite. Detecting datetimes is
surprisingly complicated since it depends on the formatting applied to the
column (datetimes are identically to numbers), so if you're dealing with unusual
formatting I may not be able to detect it, but having more examples in the test
suite would help.
cfcs asked:
That is very nice!

I must admit that my main use for generating Excel files in the past has been
that the CSV format's method to specify background colors for cells was pretty
buggy and not portable between Excel/LibreOffice, so I'm not a heavy user, but I
think this is good to have in the ecosystem!
Brendan Long then replied:
At the moment I don't really offer an interface to write XLSX files back out,
but I'd be happy to have it.

`spreadsheetml` is able to expose [cell
but it's not exposed at the `easy_xlsx` layer (since that library is meant more
for data processing. I'd like to have a more mid-level interface at some point,
where we expose the full content of the cells instead of just the data.

Other OCaml News

From the ocamlcore planet blog:
Here are links from many OCaml blogs aggregated at OCaml Planet,

Frama-C 17 - Chlorine is out. Download ithere.

An OCaml quine | Drup's thingies

Full Time: Compiler Engineer at Jane Street in New York & London

Full Time: Software Developer (Functional Programming) at Jane Street in New York, NY; London, UK; Hong Kong

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

Alan Schmitt