Previous week Up Next week


Here is the latest OCaml Weekly News, for the week of June 24 to July 01, 2014.

  1. findlib-1.5.1
  2. ReactiveML 1.09.03
  3. OUPS meetings (next event, 8th of July)
  4. Uucp 0.9.0
  5. Book reviewers wanted (again)
  6. Extending Format strings
  7. Other OCaml News



Gerd Stolpmann announced:
I just released findlib-1.5.1:

- Including the "bytes" package that is either a compat package for
  ocaml < 4.02 or a fake package for ocaml >= 4.02. The package aims
  at helping to support the transition to the new "bytes" type for
  mutable strings.
- Also installing findlib.cmxs if OCaml supports it.
- Allowing to disable camlp4 (in prep for OCaml-4.02).
- The "ppx" package property can be specified for constructing ppx-type 

Especially thanks to Peter Zotov who contributed several patches.

More documentation and download:

ReactiveML 1.09.03


Louis Mandel announced:
We are happy to announce the new release of ReactiveML:
with a new lesson in the interactive tutorial:

ReactiveML could be easily installed using OPAM : opam install rml
or directly from the source :

ReactiveML is a language similar to OCaml extended with a built-in
notion of parallel composition. It is based on the reactive
synchronous model, a cooperative concurrency model. The language is
well suited to program applications with a lot of parallel processes
which communicate and synchronize a lot such as video games or
simulation problems. ReactiveML is compiled into plain OCaml code and
thus can link or be linked to any OCaml code.

Louis Mandel for the ReactiveML development team

OUPS meetings (next event, 8th of July)


Thomas Braibant announced:
Last week, we had a very productive OCaml hacking session at IRILL.
There were around 25 active participants, and the list of things that
wre done is highly encouraging (see [1]). We look forward to organize
another session like this one!

The next OUPS meetup will be a regular meeting with talks. It will
take place at *Mozilla Paris* on the 8th of July starting at 7 pm. For
details about the location, please go [2]

The tentative program is the following one:

- Vincent Balat: Ocsigen: Web applications with Js_of_ocaml and Eliom
- Roberto Di Cosmo: Leveraging Solver Preferences to Control your
OCaml Package Manager
- Jean-Christophe Filliâtre: Lessons from the implementation of a
graph library, OCamlGraph
- Simon Cruanes: Simple and efficient iterators
- Felix S. Klock II (core dev. Rust):  An Introduction to Rust for
functional programmers (Invited talk).

There will be drinks and some food afterwards, thanks to our sponsors
for this event, LexiFi and Mozilla.



Uucp 0.9.0


Daniel Bünzli announced:
I'd like to announce uucp:

  Uucp is an OCaml library providing efficient access to a selection
  of character properties of the [Unicode character database][1].

  Uucp is independent from any Unicode text data structure and has no
  dependencies. It is distributed under the BSD3 license.


Home page:
Github mirror:

It should be available shortly in opam. A few comments about the
library can be found at the end of this message.

Part of this work was sponsored by OCaml Labs, many thanks for their



A few notes.

* Having seen unwarranted sights of horror at the simple mention of 
  Unicode by fellow peers I took the time to write an absolute minimal
  introduction to Unicode in the documentation:
  At the end of this introduction end I also give a few biased tips on
  how Unicode can be handled in OCaml.

* The data used to represent the properties is directly linked
  in your executables. In the future I will adapt the library to use
  OCaml 4.02 module aliases so that you only pay for the submodules
  you access. For now linking against the library on osx 64-bit, 
  result in a 6.4 Mo executable and on linux 32-bit a 3.7 Mo

* If you are interested in Unicode caseless matching (equality) 
  of strings or identifiers, the documentation of the Uucp.Case module
  has sample code on how to perform that using Uutf and Uunf. This
  code may eventually be gathered in a proper module in the future.

* Not all properties are exposed. Obsolete properties, deprecated
  properties and those that are specific to some unicode processing
  algorithm (bidi, segmentation, normalization, etc.) are left out.
  The reason for the latter is that these algorithm may need to devise
  their own, maybe more efficient, representations. For example the
  normalization properties are not included, as they are best stored,
  used and exposed by a module that performs normalization
  (e.g. Uunf). It is not excluded that I reverse this in the future
  and make Uunf dependent on Uucp as this could make maintenance
  easier (though Uunf sometimes uses optimized representations). 
  Also if the data needs to be used by more than one module
  this may become less wasteful than each module including its own

* Regarding the last point, the selection is subjective. If there's 
  a property you feel is useful in the wide and missing please 
  tell me (e.g. on github's issue tracker) with a good rationale and I 
  will add it. The full list of omitted properties is available here:

Book reviewers wanted (again)


John Whitington:
I have prepared another little book about OCaml, a collection of
sixteen little algorithms, methods, and diversions, together with
Questions and Answers. Not quite as beginner-ish as "OCaml from the
Very Beginning" but not, I hope, too intimidating at all.

I've included the provisional table of contents below.

Please drop me a note by email if you can spare a little time to
review a draft, which should be ready soon. Free copies for people who
provide substantive comments, like last time, of course.

1 Unravelling "Fold"
2 Being Lazy
3 Named Tuples with Records
4 Generalized Input/Output
5 Streams of bits
6 Compressing Data
7 Labelled and Optional Arguments
8 Formatted Printing
9 Searching For Things
10 Finding Permutations
11 Making Sets
12 Playing Games
13 Representing Documents
14 Writing Documents
15 Pretty Pictures
16 Adding Text

I'll also be forwarding a copy to caml at like last time, so
if you're on that list, there is no need to contact me separately.

Extending Format strings


Gabriel Kerneis:
in CIL, the module Pretty provides a Format-like
interface with a few extensions compared to usual format strings.
Implementation-wise, it uses string_of_format and re-implements most of
the logic of the pre-4.02 Format module, with Obj.magic all over the

I wondered if anyone has done something similar in their own project
(extending Format in one way or another), and if the new GADT-based
approach could provide a cleaner solution?

One thing I quite like with the current code, despite its uglyness, is
its concision. I am right in assuming that switching to GADTs would
require a lot more boilerplate?

Many thanks for any example you could provide.
Tianyi Cui suggested and Gabriel Kerneis replied:
> I found quite
> straightforward to understand and easy to use, if most of your types
> already have sexp converters and to_string functions.

Thanks. This is a nice hack (provided you are happy to use
a pre-processor). However, if I understand correctly, it is limited to
making %s and %a more convenient to use for existing Printf functions.

I should probably have given more details in my initial request. CIL's
Pretty.dprintf [1] constructs and returns a "document" (similar to
PPrint.document, if you are more familiar with this library), to be
later formated and rendered to a given width. I am not sure
custom_printf provides that level of flexibility.

Jeremie Dimino also replied and Alain Frisch added:
> I had a quick look at [Pretty.dprintf] and I think you could use
> [CamlinternalFormat.make_printf] to implement it with 4.02. @-sequences
> are already recognized by the format parser in the compiler, but it
> should be compatible with [Pretty]'s syntax, you just have to interpret
> the constructors differently. It should actually make the code of
> [Pretty.dprintf] much simpler.

We had a very similar issue with some internal LexiFi library, also
using @-markers, and returning some structured document.  Jeremie's
suggestion works very well.

The code below won't compile, but it can give you an idea on how to proceed:

let printf_k fmt_s (acc : (unit, t) CamlinternalFormat.acc) =
  let open CamlinternalFormat in
  let l = ref empty in
  let add x = l := conc !l x in
  let stack = ref [] in
  let push x = stack := (x,!l) :: !stack; l := empty in
  let err () =
    Mlfi_isdatypes.ffailwith "Mlfi_pp.printf: invalid format string
%S" fmt_s
  let pop () = match !stack with
    | (x,old) :: st -> stack := st; let nl = !l in l := old; (x,nl)
    | _ -> err ()
  let rec k = function
    | Acc_string(p, s) -> k p; add (str s)
    | Acc_char(p, c) -> k p; add (str (String.make 1 c))
    | Acc_delay(p, f) -> k p; add f
    | Acc_flush p -> k p
    | Acc_invalid_arg (_, msg) -> invalid_arg msg
    | Acc_formatting_lit (p, lit) ->
        k p;
        begin match string_of_formatting_lit lit with
        | "@[" -> push (`BoxLeft 2)
        | "@]" ->
            begin match pop () with
            | (`BoxLeft k,u) -> add (indent k u)
            | _ -> err ()
        | "@<" -> push `LineLeft
        | "@>" ->
            begin match pop () with
            | `LineLeft, u -> add (line u)
            | _ -> err ()
        | s ->
            add (str s)
    | Acc_formatting_gen (p, _) -> k p
    | End_of_acc -> ()
  k acc;
  if !stack <> [] then err ();

let printf (Format (fmt, fmt_s) : ('a, unit, t, f) format4) : 'a =
  let open CamlinternalFormat in
  make_printf (fun () acc -> printf_k fmt_s acc) () End_of_acc fmt

Other OCaml News

From the ocamlcore planet blog:
Thanks to Alp Mestan, we now include in the OCaml Weekly News the links to the
recent posts from the ocamlcore planet blog at

Notes on Naming:

Uucp 0.9.0:

Parametric HOAS with first-class modules:

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

Escaping continuations:

Reading Lamport, again:

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