Previous week Up Next week


Here is the latest OCaml Weekly News, for the week of June 16 to 23, 2015.

  1. OCaml release 4.02.2
  2. Uucd 3.0.0 & Uucp 1.0.0 & Uunf 1.0.0 & Uuseg 0.9.0
  3. ocf 0.2.0 and taglog 0.1.0
  4. BER metaocaml
  5. Labels at the module level?
  6. Other OCaml News

OCaml release 4.02.2


Damien Doligez announced:
We have the pleasure of celebrating the birthdays of Cesar-Francois
Cassini, Igor Stravinsky and Maurits Cornelis Escher by announcing the
release of OCaml version 4.02.2.
This release has a few new features and a lot of bug fixes, see the
list of changes below.

It is available:
- as source code:
- as an OPAM switch: "opam switch 4.02.2"

We would like to take the opportunity to thank all the third-party
packagers who make this easy to install for end users.

Happy hacking,

-- Damien Doligez for the OCaml team.

OCaml 4.02.2:

(Changes that can break existing programs are marked with a "*")

Language features:
- PR#6583: add a new class of binary operators with the same syntactic
  precedence as method calls; these operators start with # followed
  by a non-empty sequence of operator symbols (for instance #+, #!?).
  It is also possible to use '#' as part of these extra symbols
  (for instance ##, or #+#); this is rejected by the type-checker,
  but can be used e.g. by ppx rewriters.
  (Alain Frisch, request by Gabriel Radanne)
* PR#6016: add a "nonrec" keyword for type declarations
  (Jérémie Dimino)

- PR#6600: make -short-paths faster by building the printing map
  (Jacques Garrigue)
- PR#6642: replace $CAMLORIGIN in -ccopt with the path to cma or cmxa
  (Peter Zotov, Gabriel Scherer, review by Damien Doligez)
- PR#6797: new option -output-complete-obj
  to output an object file with included runtime and autolink libraries
  (Peter Zotov)
- PR#6845: -no-check-prims to tell ocamlc not to check primitives in runtime
  (Alain Frisch)
- GPR#149: Attach documentation comments to parse tree
  (Leo White)
- GPR#159: Better locations for structure/signature items
  (Leo White)

Toplevel and debugger:
- PR#5958: generalized polymorphic #install_printer
  (Pierre Chambart and Grégoire Henry)

- PR#6237: explicit "infer" tag to control or disable menhir --infer
  (Hugo Heuzard)
- PR#6625: pass -linkpkg to files built with -output-obj.
  (Peter Zotov)
- PR#6702: explicit "linkpkg" and "dontlink(foo)" flags
  (Peter Zotov, Gabriel Scherer)
- PR#6712: Ignore common VCS directories
  (Peter Zotov)
- PR#6720: pass -g to C compilers when tag 'debug' is set
  (Peter Zotov, Gabriel Scherer)
- PR#6733: add and targets to pass
  -output-obj -cclib -shared.
  (Peter Zotov)
- PR#6733: "runtime_variant(X)" to pass -runtime-variant X option.
  (Peter Zotov)
- PR#6774: new menhir-specific flags "only_tokens" and "external_tokens(Foo)"
  (François Pottier)

- PR#6285: Add support for nanosecond precision in Unix.stat()
  (Jérémie Dimino, report by user 'gfxmonk')
- PR#6781: Add higher baud rates to Unix termios
  (Damien Doligez, report by Berke Durak)
- PR#6834: Add Obj.{first,last}_non_constant_constructor_tag
  (Mark Shinwell, request by Gabriel Scherer)

- PR#6078: Release the runtime system when calling caml_dlopen
  (Jérémie Dimino)
- PR#6675: GC hooks
  (Damien Doligez and Roshan James)

Build system:
- PR#5418 (comments) : generate dependencies with $(CC) instead of gcc
  (Damien Doligez and Michael Grünewald)
- PR#6266: Cross compilation for iOs, Android etc
  (Peter Zotov, review by Damien Doligez and Mark Shinwell)

Installation procedure:
- Update instructions for x86-64 PIC mode and POWER architecture builds
  (Mark Shinwell)

Bug fixes:
- PR#5271: Location.prerr_warning is hard-coded to use Format.err_formatter
  (Damien Doligez, report by Rolf Rolles)
- PR#5395: OCamlbuild mishandles relative symlinks and include paths
  (Damien Doligez, report by Didier Le Botlan)
- PR#5822: wrong value of Options.ext_dll on windows
  (Damien Doligez and Daniel Weil)
- PR#5836, PR#6684: printing lazy values in ocamldebug may segfault
  (Gabriel Scherer, request by the Coq team)
- PR#5887: move the byterun/*.h headers to byterun/caml/*.h to avoid
  header name clashes
  (Jérôme Vouillon and Adrien Nader and Peter Zotov)
- PR#6281: Graphics window does not acknowledge second click (double click)
  (Kyle Headley)
- PR#6490: incorrect backtraces in gdb on AArch64.  Also fixes incorrect
  backtraces on 32-bit ARM.
  (Mark Shinwell)
- PR#6573: extern "C" for systhreads/threads.h
  (Mickaël Delahaye)
- PR#6575: Array.init evaluates callback although it should not do so
  (Alain Frisch, report by Gerd Stolpmann)
- PR#6607: The manual doesn't mention 0x200 flag for OCAMLRUNPARAM=v
  (Alain Frisch)
- PR#6616: allow meaningful use of -use-runtime without -custom.
  (Peter Zotov)
- PR#6617: allow android build with pthreads support (since SDK r10c)
  (Peter Zotov)
- PR#6626: ocamlbuild on cygwin cannot find ocamlfind
  (Gergely Szilvasy)
- PR#6628: Configure script rejects legitimate arguments
  (Michael Grünewald, Damien Doligez)
- PR#6630: Failure of tests/prim-bigstring/{big,} on big-endian
  (Pierre Chambart, testing by Mark Shinwell)
- PR#6640: ocamlbuild: wrong "unused tag" warning on "precious"
  (report by user 'william')
- PR#6652: ocamlbuild -clean does not print a newline after output
  (Damien Doligez, report by Andi McClure)
- PR#6658: cross-compiler: version check not working on OS X
  (Gerd Stolpmann)
- PR#6665: Failure of tests/asmcomp on sparc
  (Stéphane Glondu)
- PR#6667: wrong implementation of %bswap16 on ARM64
  (Xavier Leroy)
- PR#6669: fix 4.02 regression in toplevel printing of lazy values
  (Leo White, review by Gabriel Scherer)
- PR#6671: Windows: environment variable 'TZ' affects Unix.gettimeofday
  (Mickael Delahaye and Damien Doligez)
- PR#6680: Missing parentheses in warning about polymorphic variant value
  (Jacques Garrigue and Gabriel Scherer, report by Philippe Veber)
- PR#6686: Bug in [subst_boxed_number]
  (Jérémie Dimino, Mark Shinwell)
- PR#6690: Uncaught exception (Not_found) with (wrong) wildcard or unification
  type variable in place of a local abstract type
  (Jacques Garrigue, report by Mikhail Mandrykin)
- PR#6693 (part two): Incorrect relocation types in x86-64 runtime system
  (Peter Zotov, review by Jacques-Henri Jourdan, Xavier Leroy and Mark Shinwell)
- PR#6717: Pprintast does not print let-pattern attributes
  (Gabriel Scherer, report by Peter Zotov)
- PR#6727: Printf.sprintf "%F" misbehavior
  (Benoît Vaugon, report by Vassili Karpov)
- PR#6747: ocamlobjinfo: missing symbol caml_plugin_header due to underscore
  (Damien Doligez, Maverick Woo)
- PR#6749: ocamlopt returns n for (n mod 1) instead of 0
  (Mark Shinwell and Jérémie Dimino)
- PR#6753: Num.quo_num and Num.mod_num incorrect for some negative arguments
  (Xavier Leroy)
- PR#6758: Ocamldoc "analyse_module: parsetree and typedtree don't match"
  (Damien Doligez, report by user 'maro')
- PR#6759: big_int_of_string incorrectly parses some hexa literals
  (Damien Doligez, report by Pierre-yves Strub)
- PR#6763: #show with -short-paths doesn't select shortest type paths
  (Jacques Garrigue, report by David Sheets)
- PR#6768: Typechecker overflow the stack on cyclic type
  (Jacques Garrigue, report by user 'darktenaibre')
- PR#6772: asmrun/signals_asm.c doesn't compile on NetBSD/i386
  (Kenji Tokudome)
- PR#6775: Digest.file leaks file descriptor on error
  (Valentin Gatien-Baron)
- PR#6779: Cross-compilers cannot link bytecode using custom primitives
  (Damien Doligez, request by Peter Zotov)
- PR#6787: Soundness bug with polymorphic variants
  (Jacques Garrigue, with help from Leo White and Grégoire Henry,
   report by Michael O'Connor)
- PR#6790: otherlibs should be built with -g
  (Damien Doligez, report by Peter Zotov)
- PR#6791: "%s@[", "%s@{" regression in Scanf
  (Benoît Vaugon)
- PR#6793: ocamlbuild passes nonsensical "-ocamlc ..." commands to menhir
  (Gabriel Scherer, report by Damien Doligez)
- PR#6799: include guards missing for unixsupport.h and other files
  (Andreas Hauptmann)
- PR#6810: Improve documentation of Bigarray.Genarray.map_file
  (Mark Shinwell and Daniel Bünzli)
- PR#6812: -short-paths and -no-alias-deps can create inconsistent assumptions
  (Jacques Garrigue, report by Valentin Gatien-Baron)
- PR#6817: GADT exhaustiveness breakage with modules
  (Leo White, report by Pierre Chambart)
- PR#6824: fix buffer sharing on partial application of Format.asprintf
  (Gabriel Scherer, report by Alain Frisch)
- PR#6831: Build breaks for -aspp gcc on solaris-like OSs
  (John Tibble)
- PR#6836: Assertion failure using -short-paths
  (Jacques Garrigue, report by David Sheets)
- PR#6837: Build profiling libraries on FreeBSD and NetBSD x86-64
  (Mark Shinwell, report by Michael Grünewald)
- PR#6841: Changing compilation unit name with -o breaks ocamldebug
  (Jacques Garrigue, report by Jordan Walke)
- PR#6843: record weak dependencies even when the .cmi is missing
  (Leo White, Gabriel Scherer)
- PR#6849: Inverted pattern unification error
  (Jacques Garrigue, report by Leo White)
- PR#6857: __MODULE__ doesn't give the current module with -o
  (Jacques Garrigue, report by Valentin Gatien-Baron)
- PR#6862: Exhaustiveness check wrong for class constructor arguments
  (Jacques Garrigue)
- PR#6869: Improve comment on [Hashtbl.hash_param]
  (Mark Shinwell, report by Jun Furuse)
- PR#6870: Unsoundness when -rectypes fails to detect non-contractive type
  (Jacques Garrigue, report by Stephen Dolan)
- PR#6872: Type-directed propagation fails to disambiguate variants
  that are also exception constructors
  (Jacques Garrigue, report by Romain Beauxis)
- PR#6878: AArch64 backend generates invalid asm: conditional branch
  out of range (Mark Shinwell, report by Richard Jones, testing by Richard
  Jones and Xavier Leroy, code review by Xavier Leroy and Thomas Refis)
- PR#6879: Wrong optimization of 1 mod n
  (Mark Shinwell, report by Jean-Christophe Filliâtre)
- PR#6884: The __CYGWIN32__ #define should be replaced with __CYGWIN__
  (Adrien Nader)
- PR#6886: -no-alias-deps allows to build self-referential compilation units
  (Jacques Garrigue, report by Valentin Gatien-Baron)
- PR#6889: ast_mapper fails to rewrite class attributes
  (Sébastien Briais)
- PR#6893: ocamlbuild:  "tag not used" warning when using (p)dep
  (Gabriel Scherer, report by Christiano Haesbaert)
- GPR#143: fix getsockopt behaviour for boolean socket options
  (Anil Madhavapeddy and Andrew Ray)
- GPR#190: typo in pervasives
  (Guillaume Bury)
- Misplaced assertion in major_gc.c for no-naked-pointers mode
  (Stephen Dolan, Mark Shinwell)

Feature wishes:
- PR#6452, GPR#140: add internal suport for custom printing formats
  (Jérémie Dimino)
- PR#6641: add -g, -ocamlcflags, -ocamloptflags options to ocamlmklib
  (Peter Zotov)
- PR#6693: also build and lib{asm,caml}run_pic.a
  (Peter Zotov, review by Mark Shinwell)
- PR#6842: export Typemod.modtype_of_package
  (Jacques Garrigue, request by Jun Furuse)
- GPR#139: more versatile specification of locations of .annot
  (Christophe Troestler, review by Damien Doligez)
- GPR#157: store the path of cmos inside debug section at link time
  (Hugo Heuzard, review by Damien Doligez)
- GPR#191: Making gc.h and some part of memory.h public
  (Thomas Refis)
Simon Cruanes then asked and Gabriel Scherer replied:
> I know it should have been reported before, during the rc1, but anyway,
> I noticed this after the release (not my packages):
> ```
> type foo = { bar[@toto] : int };;
> ```
> This compiles on 4.02.1 (and puts the attribute [@toto] on the field `bar`)
> but fails to compile on 4.02.2 as follows:
> ```
> # type foo = { bar [@toto] : int  };;
> Error: Syntax error
> ```
> This breaks ppx_deriving (for which a patch is underway), and every
> piece of code that uses it with attributes on records, yet nothing is
> mentioned in the changelog (at least not with a "breaking" annotation)?

This change to the placement of attributes that was discussed in

It is indeed a mistake that it is not in the Changelog. As a meta-comment (not
discussing this particular patch), in the future we might need to have "a
proper Changelog line" as an explicit requirement for all submitted patches (I
would be tempted to add "a testsuite test exercising the affected features"),
because it is fairly error-prone to try to track changes to add to the
changelog after they've been merged.

The rationale for this change is that the syntax was perceived as an
improvement by the ppx-users that expressed an opinion on the issue, and they
asked for this to be released as soon as possible hoping to facilitate the
transition to the new syntax (few existing users).
The change was tested against all released OPAM packages, and riak_ppx was the
only package that broke. It seems that either (1) the code using the old
syntax had not been released as OPAM packages yet (in retrospect it seems
reasonable that using OPAM testing as only testing vehicle is rather fragile
for very recent features; on the other hand, I don't know which other tests
could be put in place) or (2) said packages did not break in a way that was
perceptible to the automated tool.

I think 4.02.2 is a slightly less minor release than is usual: it does have
some new features that are not simply bugfixes, because they were requested by
users which were eager to see them released (typically all the ppx-related
changes). This is a delicate compromise to make, and unfortunately there are
indeed a couple regressions -- despite a very silent rc1-to-release period.
The only other one I know of is .

Uucd 3.0.0 & Uucp 1.0.0 & Uunf 1.0.0 & Uuseg 0.9.0


Daniel Bünzli announced:
Unicode 8.0.0 has been released a few hours ago. It adds 7716 new characters
including the sorely missing CHEESE WEDGE (U+1F9C0) character. See [1,2] for
the full list of additions and more information.

Accordingly the following modules had to be updated. All of this should be
available in opam shortly.

# Uucd 3.0.0

New properties and new property cases having been added, this is an incompatible release.

# Uucp 1.0.0

New blocks and scripts having been added, this is an incompatible release (new variant cases).

# Uunf 1.0.0

Uunf also gets an incompatible release to fix a very stupid API quirk, see the
release notes on how to migrate code. The API is now expected to be stable. It
also introduces a new Uunf_string module that allows to directly normalize
OCaml UTF-X encoded strings (depends on Uutf); if that's your only need you
are encouraged to directly use these functions as they could get optimized in
the future. Finally it has the latest data to handle 8.0.0's characters.

# Uuseg 0.9.0

Support for 8.0.0's new line breaking and sentence boundary rules. Also adds
a small incompatible change in the custom segmenter API, see the release




ocf 0.2.0 and taglog 0.1.0


Maxence Guesdon announced:
I'm glad to announce the release of Ocf 0.2.0 and Taglog 0.1.0.

* Ocf is a library to create configuration options and read and store
  them in JSON syntax.
  See the documentation for a guided tour:
  Changes in the release:
  - fix ppx: do not build empty value declarations,
  - add Ocf.set,
  - add Ocf.Wrapper.of_ok_error to easily use code generated by

* Taglog is a library to create log functions. These log functions use
  classical log levels but also tags to determine whether to output a
  log message or not.
  See the documentation for a guided tour:

Both should be available soon in opam.

BER metaocaml


Jacques Carette asked and Anil Madhavapeddy replied:
> Two questions:
> 1. Would it be worthwhile to start a mailing list for BER-metaocaml users?

If you would like to host this on, then the process is
really easy.  Just drop a line to "" with
the name of the list, a short (one paragraph) description, and the primary
email contact(s) for moderation purposes.  The moderation is only to reject
spam emails

> 2. Where would be a good repository of BER-metaocaml examples? [I mean,
> creating one that could be used as examples to learn; I believe the opam
> repository could host "packages"?]

Somewhere on GitHub in an organisation would work well. I notice that
one already exists for BER MetaOCaml here:

Thanks for doing this!  Having a more central place with some examples
would be most useful.
Ömer Sinan Ağacan then said:
A repo for examples would be great. I have an example project which
I'd like to link from examples repo(or add it to the repo):

Labels at the module level?


Kenichi Asai asked:
Using labeled arguments, one can supply default values for unspecified

let f ?(x = 3) y = x * y
in f 5

will return 15 without specifying the value of x at the second line.
Is there a way to do a similar thing at the module level?  Namely, I
want to define a functor that accepts a module of sig:

module type A_t = sig
  val x : int
  val y : int

but if the user did not specify some of the values in the signature,
some default values will be used.

Background: in the universe library for OCaml:

one specifies various handlers for events (such as tick, mouse, and
key events).  Currently, these handlers are registered to the big_bang
function that accepts them using labeled arguments (with default
values).  I wonder if I can specify the interface as a module
signature and let the user write a module of that signature but only
those handlers that the user is interested in.
Jeremy Yallop replied:
Alain Frisch once had a patch to add exactly what you're asking for as
a language feature:   (Scroll to 'optional
fields in modules')

In the absence of such a feature, one approach is to use 'include' to
provide the defaults:

    module M
      include M_defaults
      let y = 3
Benjamin Greenman also replied:
Instead of making a functor, you could try a first-class module:

module type Person = sig
val name : string
val age : int

let make_person ?(name="anon") (age : int) : (module Person) =
(module struct
let name = name
let age = age
Oleg also repliec:
It is even easier at the module level: include comes in handy. Suppose
we have a consumer

module Universe(Params: A_t) = struct
  let r () = Printf.printf "x = %d y = %d\n" Params.x Params.y

First, we define defaults:

module Def : A_t = struct let x = 1 let y = 2 end;;

We can invoke it as

let module M = Universe(Def) in M.r ();;

and also as

let module M = Universe(struct include Def let x = 100 end) in M.r ();;

BTW, groups of related parameters could be further grouped into

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

OMake On Steroids (Part 3):

New in nbdkit 1.1.10: OCaml plugins:

OMake On Steroids (Part 2):

Release of Uucd 3.0.0, Uucp 1.0.0, Uunf 1.0.0 and Uuseg 0.9.0:

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