Previous week Up Next week


Here is the latest OCaml Weekly News, for the week of March 15 to 22, 2016.

  1. automatic differentiation
  2. opam-cross-windows
  3. Sundials/ML 2.6.2
  4. ocaml-ctypes 0.5.0, a library for calling C functions directly from OCaml
  5. Other OCaml News

automatic differentiation


Nils Becker asked:
i was looking for an AD library for ocaml. what i found was this:

is this the state of the art of what's available today?

thanks for any pointers!
Yaron Minsky replied:
Markus Mottl has something that sounds pretty cool.

But I have yet to find the code.  Markus, is your new ad package going
to be open sourced at some point?
Markus Mottl replied:
there are no imminent plans to make a release of the code for AD-OCaml
yet.  I'm still working on it, and once it reaches a sufficient level
of maturity, I'll determine what the next step will be, making it open
source being one of the options.
Guillaume Hennequin also replied:
I agree, it sounds really useful! I gave a shot at AD in OCaml a couple of
months ago, with inspiration coming from F#'s autodiff by Barak Pearlmutter . I got to a working implementation of
forward/reverse/forward-on-reverse but I really struggled with the complexity of
the functorial interface I needed to achieve compositionality -- lack of
operator overloading somehow makes life difficult here. So really curious to see
Markus Mottl's solution. Happy to share my code with anyone interested though.



Continuing a thread, Andreas Hauptmann said:
> Ideally I would like to have an opam running on plain windows,

I (sometimes) maintain a windows repository for opam and an opam build

To a certain extent, it is "plain windows": neither opam nor OCaml are
linked against cygwin. However, cygwin is still necessary for nearly
everything else: git, rsync, a shell to run configure scripts, make, ...

Sundials/ML 2.6.2


Timothy Bourke announced:
We are pleased to announce a new release of Sundials/ML, an OCaml
interface to the Sundials suite of numerical solvers (CVODE, CVODES,

This release includes support for all new features in Sundials 2.6.x
(namely the ARKODE solver, OpenMP and Pthreads nvectors, sparse
matrices, and the KLU and SuperLU/MT linear solvers), but continues to
work with the older version (2.5.0) that is still provided by many
packaging systems.

Information and documentation:
Source code (BSD):   

    opam install sundialsml   # (requires Sundials 2.5.0 or above)

There is a draft report that describes our implementation. It is not
quite ready for public release, but we would be happy to share it by
private mail.

We gratefully acknowledge the original authors of Sundials, and the
support of the ITEA 3 project 11004 MODRIO (Model driven physical
systems operation), Inria, and the Departement d'Informatique de

Timothy Bourke, Jun Inoue, and Marc Pouzet.

ocaml-ctypes 0.5.0, a library for calling C functions directly from OCaml


Jeremy Yallop announced:
I'm pleased to announce release 0.5.0 of ocaml-ctypes, which is now
available on OPAM.

== About ocaml-ctypes ==

The ocaml-ctypes library makes it possible to call C functions from
OCaml without writing any C code.  The core of the library is a set of
combinators for describing C types -- scalars, functions, structs,
unions, arrays, and pointers to values and functions.  Type
descriptions can then be used to bind native functions and values.
Here's a simple example:

    # let puts = foreign "puts" (string @-> returning int);;
    val puts : string -> int = <fun>
    # puts "Hello, world!";;
    Hello, world!

Ctypes includes many more features, including functions for retrieving
constants, values and details about object layout from C, a way of
building C libraries from OCaml modules, and a variety of binding
strategies such as dynamic linking and static stub generation. Further
information is available at the links below:

  Some packages using ctypes:
  API documentation:
  Github repository:
  Direct download:

== Selected new features in 0.5.0 ==

* Improved support for various standard C and POSIX integer types
  (time_t, ssize_t, ptrdiff_t, intptr_t, uint8_t, and many more).

* Improved support for conversions between function pointers and other
pointer types

* Support for releasing the runtime lock in the Cstubs_inverted module.

* An experimental interface for managing OCaml roots.

See the release notes for the full list of changes:

== Thanks ==

I'm grateful to Andreas Hauptmann, David Sheets, Etienne Millon,
Goswin von Brederlow, Leonid Rozenberg, @orbitz, Max Mouratov, and
Peter Zotov for contributions to this release.
sp asked and Jeremy Yallop replied :
> Great work, thank you!
> Are there areny plans to support C++ in a similar approach?

It'd be possible to support some of C++ fairly straightforwardly.  For
example, binding overloaded functions should work with the current
ctypes release if you use stub generation (i.e. the Cstubs module),
and calling function templates will probably work too.  It'd be a bit
more work to support exceptions and member functions, but it could
probably be done.  C++ support is not currently high up on the
priority list, but I'd be happy to help out if someone wanted to start
looking at a design.
Goswin von Brederlow asked and Jeremy Yallop replied:
> Does anyone have an example of using ctypes with stub generation using
> oasis?

OPAM suggests that there are a few:

$ comm -12 <(opam list --short --depends-on oasis) <(opam list --short
--depends-on ctypes)

Here's the link to the homepage for the first result, which has some
oasis and ocamlbuild rules for ctypes stub generation:

$ opam show -f homepage flock

Other OCaml News

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

Format All the Data Structures

Unraveling of the tech hiring market

A Machine Made this Book: Ten Sketches of Computer Science

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