OCaml Weekly News

Previous Week Up Next Week


Here is the latest OCaml Weekly News, for the week of July 24 to August 21, 2018.

Table of Contents

Color: library to work with css color formats

Continuing this thread, gasche said

Would there be a chance to connect with the work on specifying colors and color profiles in @dbuenzli's basic graphics Gg library (see Gg.Color documentation)? From the interface that you provide, it is not completely clear to me how flexible color computations can be – you provide an HSLA color space, but a linearized sRGB space would be also convenient for example, and Gg provides one.

Christophe added

To work with colors, note there is also Color brewery (not yet in opam) which is compatible with Gg.color. I concur with @gasche, it is good if all these libraries can work together.

Anurag Soni then announced


I have updated the library with more utilities to work with colors. Some other changes since last time is the use of Gg.Color.t as the color type. So one can use other methods from the wonderful gg library to tweak/modify their colors, or use color palettes like the ones from color-brewry

Derive-ocaml: a rust crate to help with ocaml FFI

Joris Giovannangeli announced

i'm pleased to announce the first release of derive-ocaml a set of rust macros 1.1/2.0 (similar to ppx) to generate boilerplate of writing rust stubs for ocaml external calls.

The crate has no runtime and relies on the ocaml for all the ocaml runtime bindings.

The macros are still a bit experimental but should make ocaml/rust ffi much easier to crawl. Also while here i'd like to thank @zshipko for maintaining and improve the ocaml crate !!

Perry E. Metzger asked and Joris Giovannangeli replied

> So this is to allow calling Rust from OCaml?

yes,but mostly it's helper to derive conversion from and to ocaml types to rust structures/enums. This is the main feature, it generates boilerplate code to call store_field()/field 'macros' like in C. On top of that it has some glue to make rust functions "nice" looking by hiding CAMLparams and co macros.

You can see a very basic example here:

random forests in OCaml via bindings to the R randomForest package

UnixJunkie announced


Quite hackish but working. The interface is similar to my other "R-wrapping packages". Data are exchanged via text files.

Should land soon in opam.

OCaml Documentation Open Thread

Deep in this thread, Daniel Bünzli said

> but even plain text files of good documentation

We even have better than that.

We have the ocamldoc language. It allows to have your documentation exactly where it is needed, in mli files, and will carry itself if you move your sources around.

The ocamldoc language is a fully featured document markup language with sectioning and checked cross references to sections and API entry points.

Doing manuals and tutorial inside .mli always felt a bit cumbersome but is entirely doable as can be witnessed in many of my packages (see this one for example). The good news is that nowadays we will gradually be able to write those larger pieces in seperate .mld files. Code sample extraction is not there yet but I hope we can have a simple design implemented soon rather than having these discussions.

The other good news is that as a programmer, the effort you need to provide in order to make the documentation you write in this language available to end-users is this: approaching zero:

  • If you are using topkg or dune-release (assuming they didn't kill that workflow), publishing your docs online on github is a topkg distrib && topkg publish doc away.
  • Distributing this documentation with your package releases is also automatically done if you use topkg+ocamlbuild or dune: these systems compile and install the right files which odig can then pickup in order to generate cross-referenced documentation for all the packages that are installed in your opam switch and allows you to peacefully read all this wondefully produced documentation offline with the stylesheet that suits you.

One might complain that the ocamldoc language syntax is none of these alternative document markup languages whose popularity came after ocamldoc's initial existence but if you ever tried to write a polymorphic variant in a markdown code span you will be glad that ocamldoc's language isn't that one.

I understand the ocamldoc language is one more thing to learn as a newcomer but it's not hugely complex, it's there, it works with the advantages highlighted above and an aspiring OCaml working programmer shall meet it quite soon anyways since there are thousands of lines of documentation in hundreds of projects that are using it.

Article: "Systems Languages: An Experience Report"

Deep in this thread, Yotam Barnoy announced

Just wanted to plug OCamlverse. Not only can anyone contribute via PR, anyone can have commit rights as well.

We already have a quickstart page for setting up Dune and such. I'd love to have more content there for getting OCaml concepts like concurrent programming up and running quickly.

Opam 2.0.0 RC4-final is out!

R. Boujbel announced

We are happy to announce the opam 2.0.0 final release candidate. Hooray! :tada: It will be promoted to 2.0.0 proper within a few weeks, when the official repository format switches from 1.2.0 to 2.0.0. You'll find all information about opam update & repository upgrade in this blog post.

Big thanks to all who helped test and polish the release!

R. Boujbel later said

The roadmap is detailed in this blog post.

Updated dune starter kit

Martin Jambon announced

The goal of this 3rd-party repository is to provide a minimal and idiomatic template for setting up an OCaml project. It was just updated to use dune instead of jbuilder.

For those migrating, the changes are minimal and detailed migration help is given by the official docs.

Shon then said

I have a dead simple, feature poor tool in this direction which I've used for my own toy purposes: https://github.com/shonfeder/nomad

Its in't updated to use the dune rebranding or to be compliant with the new release.

I'm glad to hear that the views about integrating this functionality directly into dune have changed! I'd be happy to help with that effort.

Quantitative developer position at LexiFi, Paris

Alain Frisch announced

LexiFi has an open position for a junior quantitative developer. The position could be a good fit for an OCaml developer with some interest in (learning about) numerical methods and/or financial stuff, even without a formal background in those topics.

More information: https://www.lexifi.com/careers/quantitative-developer/

Dune 1.1.0

Rudi Grinberg announced

On behalf of the dune team, I'm proud to announce the 1.1.0 release of dune. This release contains a few interesting features that I won't describe in this post, because I've already written a dedicated blog post about this release: http://rgrinberg.com/posts/dune-upcoming-1-1/

The change log is replicated here for your convenience:

1.1.0 (06/08/2018)

  • Fix lookup of command line specified files when --root is given. Previously, passing in --root in conjunction with --workspace or --config would not work correctly (#997, @rgrinberg)
  • Add support for customizing env nodes in workspace files. The env stanza is now allowed in toplevel position in the workspace file, or for individual contexts. This feature requires (dune lang 1.1) (#1038, @rgrinberg)
  • Add enabled_if field for aliases and tests. This field controls whether the test will be ran using a boolean expression language. (#819, @rgrinberg)
  • Make name, names fields optional when a public_name, public_names field is provided. (#1041, fix #1000, @rgrinberg)
  • Interpret X in --libdir X as relative to PREFIX when X is relative (#1072, fix #1070, @diml)
  • Add support for multi directory libraries by writing (include_subdirs unqualified) (#1034, @diml)
  • Add (staged_pps ...) to support staged ppx rewriters such as ones using the OCaml typer like ppx_import (#1080, fix #193, @diml)
  • Use -opaque in the dev profile. This option trades off binary quality for compilation speed when compiling .cmx files. (#1079, fix #1058, @rgrinberg)
  • Fix placeholders in dune subst documentation (#1090, @emillon, thanks @trefis for the bug report)
  • Add locations to errors when a missing binary in PATH comes from a dune file (#1096, fixes #1095, @rgrinberg)

Work-in-progress Sentry SDK

Brendan Long announced

Cross-posted-ish from: https://forum.sentry.io/t/a-work-in-progress-ocaml-sdk/4406

I've been wanting to use Sentry with OCaml, and ended up writing my own library for it. I thought other people might be interested to, so:


It currently only works with Async and not Lwt or synchronous/stdlib only. If anyone else is interested, I'd definitely like to support those. And feedback would definitely be nice.

You basically just do this at the start of your program and it will load SENTRY_DSN (and some other things) from your environment and upload any errors in the background:

Sentry.with_context  @@ fun () ->

You can also set custom tags and upload exceptions or messages manually:

Sentry.with_environment "staging" @@ fun () ->
Sentry.with_tags [ "method", "POST" ; "path", "/example" ] @@ fun () ->
Sentry.capture_message "this will have the environment and tags above merged with the defaults"

Results look like:


Note that it works a lot better if you use exceptions and not Or_error.t, although if someone wants to improve the Or_error.t parsing, pull requests would be welcome for that too.

A good summary of the "multicore OCaml memory model" article

gasche announced

The morning paper is an amazing blog where the author posts summaries of research papers. Today's edition covers the recent (PLDI 2018) article (PDF) on the memory model proposed for the Multicore OCaml implementation:

Bounding data races in space and time – part I

gasche later added

Part II is now available.

Balancer 1.0

Nobody Gone announced

I'm pleased to announce that Balancer 1.0 is now available on opam, it's a collection of load balancing algorithms, such as p2c, consistent hashing + least loaded, p2c with partial key grouping, round robin, etc.

All of the balancers are written with service discovery in mind, so you can plugin a react signal and use a watch with zookeeper or whatever.

It also comes with some useful synchronization utils for shared mutable state.

I think it's a useful addition to the ecosystem, just because people scale ocaml by spawning a lot of processes and talking via tcp, domain sockets, files, etc, and I'm actually surprised there wasn't a library for it beforehand.



Interesting OCaml Articles

Continuing this thread, Yotam Barnoy announced

Opam 2.0 experimental PPAs

Anil Madhavapeddy announced

I've refreshed the opam2 PPA infrastructure to make binary packages available for Ubuntu, ahead of the stable release of opam 2.0.0. These can be used with (e.g.) Travis CI for non-container based builds from an Ubuntu base, without having to wait for the upstream packages to get the latest version of opam.

The packages currently sit in my experimental PPA tree at avsm/ppa-opam-experimental, so if anyone can test them and let me know if you run into any problems, I'd appreciate it.

Sources to the scripts and more information in the README:

If anyone would like to help with including opam 2 in more upstream distributions as we approach release, please refer to the distributions wiki and pick your favourite OS :)

aws-s3 4.0.1

Anders Fugmann announced

I’m happy to announce aws-s3 4.0.1

The aws-s3 library provides access to Amazon Simple Storage Solution (S3). Operations include: get, put, head, delete, delete_multi, ls, multipart upload and s3 to s3 copying. The library includes functions to get machine role and security token (credentials) through AWS Identity and Access Management service (IAM). The library supports both lwt and async concurrency models.

Lots of changes have been made in this release, but most noticeably is the introduction of a streaming api, which will reduce latency and memory footprint as objects does not need to be held in memory in full during transfer.

The release contains some trivial breaking changes (module renaming), and upgrading should be strait forward.

Changes since version 3.0.0:

  • Support HEAD operation on objects.
  • Change signature to use string for etag rather than Caml.Digest.t
  • Support Digest 0.6
  • Remove dependency to Core
  • Rewrite authentication code
  • Switch to use Ptime for time conversion routines
  • Support chunked transfer (put)
  • Add streaming API
  • Remove dependency on Cohttp
  • Switch to dune
  • Support IPv6
  • Add option to use expect-100.
  • Add option to limit result of ls
  • Extend aws-cli
  • Move region related functions to own Region module
  • Fix bug when parsing multi delete reply in case of error

The package is available through opam.

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.

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