Previous week Up Next week


Here is the latest Caml Weekly News, for the week of July 30 to August 27, 2013.

Sorry for the hiatus, I was away for three weeks with tethering-only internet access.

  1. OCaml-Java: blending OCaml & Java
  2. Book announcement: "Parallel and Concurrent Programming in Haskell"
  3. New iteration of the Windows installer
  4. WODI (beta4) (Windows port of GODI)
  5. Call for Participation: CUFP 2013
  6. Real World OCaml beta2 now available (final beta)
  7. ocaml+opam in Cloud9 IDE
  8. OCaml-RDF 0.6.0
  9. Turning floating point errors into exceptions
  10. CamlPDF 1.7
  11. OCaml 4.01.0+beta1
  12. Merlin 1.3 -- advanced Vim and Emacs editor modes
  13. Threads and "transaction isolation" in OCaml
  14., literate assertions for OCaml
  15. Other Caml News

OCaml-Java: blending OCaml & Java


Xavier Clerc announced:
OCaml-Java is a project whose goal is to provide a compiler
targeting the JVM. The related objectives are to gain access
to a greater number of libraries, and to be able to take advantage
of multiple cores.

During the past few months, OCaml-Java has greatly evolved
and now contains the necessary mechanisms to easily blend
OCaml and Java in a single application, and to develop multicore

To access OCaml code from Java code, a tool (namely "ocamlwrap")
allows to generate Java class definitions mapping OCaml types
and values to Java elements. An overview of the tool is available
at the following address:

To access Java code from OCaml code, an extension to the original
OCaml typer allows to create and manipulate Java instances from
purely OCaml code. The typer extension is presented at the
following address:

To take advantage of multiple cores, various abstractions are
provided by the newly-introduced "Concurrent" library. It features
low-level abstractions such as threads and locks, but also high-level
abstractions such as map/reduce computations and parallel
operations over arrays. An introduction to the library and its
ocamldoc-generated documentation can be reached at the following

The project is available as a binary distribution, just needing an
installed Java 1.7 SDK to be used. The binary distribution can be
downloaded at:
while the bugtracker can be reached at:

To conclude, I would like to acknowledge the OCaml Labs for
welcoming me. A significant part of this work has actually been
performed while visiting the OCaml Labs.

Book announcement: "Parallel and Concurrent Programming in Haskell"


Francois Berenger announced:
The book is written by Simon Marlow
and published by O'Reilly.

OK it's for Haskell, but I'm sure
some people in here will be interested.

There is a free online reading link:

New iteration of the Windows installer


Jonathan Protzenko announced:
Dear OCaml programmers using Windows,

I'm happy to announce a new iteration of the Windows installer that I'm 
currently maintaining. The installer installs /native/, 32-bit OCaml 
compilers, that produce /native/, 32-bit windows programs. The OCaml 
native compiler ("ocamlopt") and tools (flexlink) requires a proper 
toolchain to be installed, namely the 32-bit one from the mingw64 
project. This toolchain is impeccably packaged in Cygwin, so the 
installer will advertise the use of cygwin as a development 
environment. Some other tools require the presence of Unix-like 
utilities; OCamlbuild, for instance, requires bash to be available. 
This is also achieved by using Cygwin as a development environment. The 
installer also installs findlib.

The installer does _not_ install any other OCaml library. This is the 
job of a package manager; unfortunately, there is still a long way to 
go on Windows. If I can tweak anything in the installer that would ease 
the life of a package manager, please let me know.

This release fixes several bugs that have been mentioned on this list.
- The Cygwin mirror is no longer hardcoded. The original idea was to 
save the user one more setup screen, where they have to choose which 
Cygwin mirror they use; mirrors, however, seem to come and go pretty 
fast, which probably explains why people witnessed packages which were 
not installed properly.
- The URL to the ActiveTCL installer has been updated.
- Flexdll has been updated to v0.31
- findlib.cmxa is now also packaged.

The installer is available at

Please give it a try and let me know how things work. If everything 
goes fine, I'll make this the default installer advertised on

WODI (beta4) (Windows port of GODI)


Andreas Hauptmann announced:
I am pleased to announce a new release of WODI (beta4).

Cygwin recently updated their mingw-w64-toolchains and various build
related tools (e.g patch). This has led to inconveniences with
previous versions of WODI.[*]

This release (hopefully) fix these issues and provides new and updated
binary packages (compatible with the mingw-w64 4.7.x-toolchain, but not
4.5.x) [**]

WODI is an extended Windows port of GODI (and still maintained at the
moment). Its build system and package tools rely on Cygwin, but the
libraries and programs, compiled with mingw-w64 and OCaml, are
independent of Cygwin.

WODI can compile ocaml related software from source or can install
already compiled packages. The compiled packages are available as 32-bit and
64-bit versions.

By default WODI installs the ocaml compiler (4.00.1) itself, flexdll
and findlib. Ocamltop-GTK and ocaml-top are now included as replacement
to the dated OcamlTopWin.

Additional software can be installed through a small package
management tool.

Among others:
- alternatives to the standard library:
    batteries, extlib and Jane Street's Core_kernel (!?)
- various build tools:
    omake, oasis
- common external c libraries with their bindings:
    pcre, lablgtk2, zarith/gmp, zlib, ...
- "pure" ocaml libraries:
    xmlm, re, camomile, ...
- editors:
    ocamleditor and emacs (with optional support for ocp-indent)

A complete list can be found here:
(Caution! Many libraries are just adopted from the original godi
repository or their build instructions were generated from _oasis

Installers can be downloaded at:

The installer will first try to create (or update) a cygwin
environment and then install GODI itself. However, the installer could
fail, if BLODA is involved
( ) Instructions for
manual installation can also be found at the address above.

Suggestions, comments and bug reports are welcome.  I'm particular
interested in your experience with certain packages, e.g. core_kernel
and dependencies as well as other common libraries with c stubs.


[*] The mingw-w64 toolchain (necessary to compile ocaml programs) and
various unix like tools (needed by GODI) are maintained by the cygwin
community; WODI by me. Therefore, such inconveniences can happen from
time to time.

[**] The packages are incompatible with previous versions of wodi.
A binary update through the package manager is not possible.

Call for Participation: CUFP 2013


Thomas Gazagnaire announced:
Hope to see some of you at CUFP this year! The program looks great, with a nice
talk by Facebook folks on how they use OCaml to analyze and type their internal
PHP codebase.

Commercial Users of Functional Programming (CUFP) 2013 at ICFP 2013;
Boston, MA, Sep 22-24.
Call for Participation
Functional programming has been at the forefront of a new generation
of programming technologies: Companies employing functional
programming use it to enable more effective, robust, and flexible
software development.
The annual CUFP workshop is designed to serve the growing community of
commercial users of functional programming: Practitioners meet and
collaborate; language designers and users can share ideas about the
future of their languages; experts share their expertise on practical
functional programming.
CUFP 2013 begins with a day of talks about industrial applications of
functional programming, followed by two days of tutorials by top-notch
language experts including advanced tutorials on special topics.
More information about CUFP 2013 is available on the CUFP web site at
Registration is available at:
Note that early-registration discounts end August 22.
Keynote: "Small Talk" Dave Thomas, TBA.
Analyzing PHP statically (Julien Verlaguet, Facebook)
Introducing Erlang to OpenX (Anthony Molinaro, OpenX)
Redesigning the Computer for Security (Tom Hawkins, BAE Systems)
End to end Reactive Programming (Jafar Husain, Netflix)
Medical Device Automation using Message-Passing Concurrency in Scheme
(Vishesh Panchal & BobBurger, Beckman Coulter Inc.)
Enabling Microservice Architectures with Scala (Kevin Scaldeferri,
Gilt Groupe)
Functional Infrastructures (Antoni Batchelli, PalletOps)
Realtime MapReduce at Twitter (Sam Ritchie, Twitter Inc)
Functional Probabilistic Programming (Avi Pfeffer, Charles River
Building a commercial development platform Haskell, an experience
report. (Gregg Lebovitz, FP Complete)
Common Pitfalls of Functional Programming and How to Avoid Them: A
Mobile Gaming Platform Case Study (Yasuaki Takebe, GREE, Inc)
Building scalable, high-availability distributed systems in Haskell
(Jeff Epstein, Parallel Scientific)
Functional Reporting (Edward Kmett, S&P Capital IQ)
Enterprise Appointment Scheduling with Haskell (Ryan Trinkle,
Programming Map/Reduce in Mathematica (Paul-Jean Letourneau, Wolfram)
T1: Haskell Day 1 (Andres Löh)
T2 - OCaml tutorial (Yaron Minsky & Anil Madhavapeddy)
T3 - Erlang 101 - Your introduction to Concurrency and Multi-core
(Francesco Cesarini & Simon Thompson)
T4 - (Systematic generation of optimal code with MetaOCaml) Oleg
T5 - (Erlang Web frameworks) Steve Vinoski
T6 - Haskell Day 2 (Simon Marlow)
T7 - Clojure tutorial (Luke Vander Hart)
T8 - The Seductions of Scala (Dean Wampler)
T9 - Bending Clojure to your will: Macros and Domain Specific
Languages (Leonardo Borges)
T10 - Scalding - The Scala Tool for Data Analytics in Hadoop Systems
(Dean Wampler)

Real World OCaml beta2 now available (final beta)


Anil Madhavapeddy announced:
The second and final public beta of Real World OCaml is now available:

Release notes:

* Over 2,000 comments from proofreaders have been resolved.  We realize that
  reading early content is hard work, and hugely appreciate the spirited
  feedback!  The book is now a week away from being handed over to the
  O'Reilly production team for copyediting, so the window for changes are
  limited after that.  Comments reset between milestones and so beta2 is a
  clean slate; we're still working through some remaining older issues.

* The chapters on first-class modules, parsing with Menhir, and objects
  and classes have been significantly revised from beta1. Our thanks to
  Leo White for contributing significantly to the latter two chapters.

* All the code snippets and terminal outputs are now mechanically generated.
  The source code is as close to public domain as practical, at:

* The final version will have the installation chapter moved to be online
  only, and we intend to publish updates there to elaborate on installation
  and packaging mechanisms.

* Exercises will be available after we go into production, and also only be
  available online. We really like the collaborative spirit of the commenting
  system, and will likely extend this to collecting exercises from our readers
  on an ongoing basis.

More at:

ocaml+opam in Cloud9 IDE


Mike Lin announced:
I devised a procedure for getting ocaml & opam bootstrapped inside a Cloud9
IDE workspace, allowing one to compile and test programs "in the cloud"
through their web application. Pretty neat to play around with!

OCaml-RDF 0.6.0


Maxence Guesdon announced:
It is my pleasure to announce the release of OCaml-RDF 0.6.0,
which now implements Sparql 1.1 Query.

Details and examples are on the new web site:

OCaml-rdf 0.6.0 will be available in opam as soon as my pull request is

Turning floating point errors into exceptions


Yaron Minsky asked and Xavier Leroy replied:
> This is really bringing up a rather old question to see whether the
> state of the world has changed when it comes to handling floating
> point exceptions.  Here's the thread on this topic from 2003.
> The key question is: is it possible to cause floating point operations
> that generate values like NaN and inf to instead generate exceptions.
> The answer from Xavier as of 2003 is: no, there's no good way of
> portably catching a synchronous error like SIGFPE.  Apparently this is
> in part due to the state of the C standards of the time.
> So, I'm curious whether things have changed enough such that this
> would now be easier.

Not really.  There are three different issues:

1- No portable way to turn floating-point exceptional conditions
(generation of a NaN, etc) into a signal.

C99 standardizes a <fenv.h> interface to select which exceptional
conditions to track and to test which exc.cond. occurred in the past.
Their docs talk about "exceptions" and "raising exceptions", but I
find this misleading as (AFAIK) no change in control-flow occurs when
such an exceptional condition occurs: it's just recorded somewhere for
later testing.

The GNU C library adds a feenableexcept() function that does what you
want, i.e. trap (generate a signal) when a selected exceptional
condition occurs.  I don't think it is available under MacOS X or the
BSDs, although equivalent functionality is available under different
names.  And of course Microsoft's CRT library doesn't even implement
<fenv.h> ("C90 ought to be enough for everybody") and has its own
nonportable functions for this purpose.

In short, this is one of these problems where it's easier to write
inline assembly for each platform of interest than to find the
appropriate nonstandard function of the C library.

2- Hard to turn a synchronous signal into an OCaml exception.

Well, ocamlopt does it for stack overflow conditions, but the code is
an #ifdef fest and it's not guaranteed that you'll get a useable stack
backtrace out of it.  Also, it works only if the synchronous signal
occurs in OCaml code: if it occurs in C code, there is not enough
context to generate an OCaml exception, and the only option is to kill
the program.  This leads to issue #3:

3- Does your libm (the C math library we use for sin, cos, log, exp,
etc) still works if exceptional FP conditions cause traps?

I have no idea.  But I wouldn't be surprised if some of these
functions can produce denormals internally even when the final result
is a normal FP number.  So, if you trap on denormals, your program
will be killed.

> The issue came up again because I've been showing OCaml to a
> physicist friend who asked how to turn on this behavior in OCaml, a
> thing he's used to from Fortran and considers essential for
> debugging.

If all your physicist friend want is the Fortran behavior (trap on
exceptional FP conditions and either kill the program or drop to the
debugger), your physicist friend could probably get it by linking with
a tiny OCaml/C library that just sets the FP processor to "trap" on
the conditions of interest.  Writing such a library is left to this
esteemed OCaml community :-)

Proper Caml-style handling of traps as catchable exceptions is
probably too hard to get right, for reasons explained above.

One last word for your physicist friend: trapping on NaNs and working
in a debugger is no substitute for proper numerical analysis.  What I
mean is that properly-written numerical libraries don't generate
exceptional FP conditions when given valid inputs, and provide ways to
validate their inputs.

CamlPDF 1.7


John Whitington announced:
The first new release of the CamlPDF library for a while is here:

(Or, shortly, via OPAM.)

The documentation is online here:

A little introduction is here:

Most importantly, CamlPDF is now open source, being under a standard 
LGPL with linking exception licence.

This release is much cleaner: development has moved to Github for 
transparency, ocamlfind is supported, and it should compile 
out-of-the-box with no dependencies on Windows, Mac and Linux. 
Documentation is much improved.

And, of course, there's lots of new functionality, such as 256 bit AES 
encryption, reading of malformed files, support for writing with object 
streams, and new modules for merging files, bookmarks, destinations. 
It's also very much faster.

There have, however, been significant non-backward-compatible API 
changes. These will be minimized in the future. Contact me directly or 
via the Github issue system if you need help updating code from a 
previous version.

OCaml 4.01.0+beta1


Damien Doligez announced:
The beta version of OCaml 4.01.0 is now available here:

This is released as source-only, for your testing pleasure. The release candidate is scheduled for the end of this month, so don't please waste time in testing and reporting bugs.

Happy hacking,

-- Damien Doligez for the OCaml team.

Compatibility notes:

The following software will need minor adjustments to run with this release (as compared to the svn version of June 13):

- camlp5 6.10: warnings.mli has changed. Version 6.11 will be available very soon.
- obrowser 1.1.1: stdlib/printexc.{ml,mli} have changed (functions added).
- lwt 2.4.0: otherlibs/unix/unix.mli has one more constructor (O_CLOEXEC) in type open_flag.
- core-109.37.00: same reason.
Anil Madhavapeddy then said:
I've added an OPAM switch for this to make it easier to try out, so you
should be able to:

$ opam update
$ opam switch 4.01.0beta1
$ opam install lwt core utop

> Compatibility notes:
> The following software will need minor adjustments to run with this release
> (as compared to the svn version of June 13):
> - camlp5 6.10: warnings.mli has changed. Version 6.11 will be available
> very soon.
> - obrowser 1.1.1: stdlib/printexc.{ml,mli} have changed (functions added).
> - lwt 2.4.0: otherlibs/unix/unix.mli has one more constructor (O_CLOEXEC)
> in type open_flag.
> - core-109.37.00: same reason.

I've added local patches for the last two into OPAM so they'll work until the
releases catch up.
Daniel de Rauglaudre said:
> - camlp5 6.10: warnings.mli has changed. Version 6.11 will be
> available very soon.

Done. Version 6.11 available at
Jonathan Protzenko said:
A corresponding installer for testing OCaml 4.01.0 on Windows is now
available here:

Please let me know if there are any bugs in the installer itself.

Merlin 1.3 -- advanced Vim and Emacs editor modes


Gabriel Scherer announced:
Merlin is an editor-assistant for the OCaml programming language,
focusing on working incrementally on incomplete files that are being
It has both a Vim and an Emacs mode (we warmly welcome
additional frontends), and provides advanced compiler-aware features
such as type-aware completion, type information feedback, and
interactive warning and error feedback.

Merlin is available at:

Merlin 1.0 was released on April 11, and the last version, Merlin
1.2, on July 21. As a sign of improved stability, we have received no
bug reports between Merlin 1.2 and the tagging of this new release,
which therefore focused on new features -- so that we can get more
bugs to fix before 1.4...

You can find a detailed changelog at, but the
highlights are:

- There is a new "locate" command, to find the definition location of
  the identifier under the cursor, much like the venerable ocamlspot
  project. It works out of the box for identifiers defined in the
  local buffer (this is where merlin shines), and relies on presence
  of .cmt files for external modules. It is bound to the :Locate
  command in vim, and merlin-locate, C-c C-l by default, in emacs.

- There is now specific support for OMake's polling mode: if you
  invoke OMake with our `omake-merlin` wrapper
    omake-merlin omake ...
  each recompilation will instruct merlin to reload the interfaces
  that changed.

- Merlin now accepts the "type nonrec", "with compare" and "with
  fields" syntax extensions -- but there are still a few glitches
  being ironed out

- The emacs mode now has "semantic movement" commands to move to the
  next or previous phrase (C-c C-p, C-c C-n)

- The vim mode's :TypeOf command now accept an optional argument, an
  OCaml expression or constructor name that will be type-checked in
  the environment at the cursor position.

This release was brought to you by Simon Castellan, Thomas Refis and
Frédéric Bour. Previous unannounced releases also received helpful feedback
and contributions from Rudy Grinberg, Anil Madhavapeddy, Andrew Noyes,
Gabriel Scherer and Marc Weber.

Merlin relies on its benevolent contributors, which you should not
hesitate to join. We warmly welcome any feedback, bugreport, and of
course documentation and code contributions.
Thomas Refis then added:
Thank you Gabriel for the announce, you beat us to it!

Here are a few things I think are missing from your post :

- Merlin is available on opam, so people willing to try it can just
call "opam install merlin"

- apart from the few things Gabriel selected from the changelog, I
think it is worth mentioning that the emacs mode of merlin was the
subject of a lot of work. There has been several bugfixes, and we know
have a much better support for emacs 23. The experience should really
be noticeably better.

- the version of merlin available on opam at the moment will only work
with ocaml 4.00.1.
If you want to use the 4.01beta or even trunk, the version of merlin
actually on opam won't work.
We have however started working on supporting more recent versions of
ocaml, we're in a "nearly releasable" state I'd say. So an opam
package (merlin-trunk probably) should appear soon. In the meantime
you can try the branch "ocaml-trunk" of our git repository.

That's about it.

As Gabriel said : feedback of all kind is very welcome!

Threads and "transaction isolation" in OCaml


Markus Mottl asked and Xavier Leroy replied (see the archive link for the full context):
> I just wondered how much we can rely on current OCaml-semantics where
> context-switches are impossible as long as there are no allocations.
> [...]
> But, surprisingly to me, I did manage to get a failure with byte code
> + POSIX threads when running this example on Linux (Centos 6.4) via
> VMware Fusion (Mac OS X).

Bytecode and native code poll for asynchronous events (context
switches, pending signals, etc) at different program points:

- Bytecode:
    . at every function call
    . at the beginning of every iteration of a while or for loop
    . at the end of "b" in "try b with ...".

- Native:
    . at every allocation in the minor heap.

Your example has a function call in the "transaction", hence the
behavior you observe.

> Anyway, is it considered reasonably future-safe to write code of that
> sort?  I'd rather not have new compiler optimizations, etc., interfere
> with these assumptions in the near future.

There is no short-term plan to change this behavior, but no guarantee
that it will be here forever.  Caveat emptor., literate assertions for OCaml


Mike Lin announced: is a little library for writing assertion statements in a
domain-specific language roughly resembling plain English. This makes
lengthy series of assertions (such as in unit tests) a little nicer to read
- example pasted below. Through some mild abuse of objects and operators, I
avoided the need for any preprocessor or syntax extension.
opam update && opam install should

Happy testing!


open Should

let int_test_case () =
    let x = 123 in begin
        x $hould # equal 123;
        x $hould # not # equal 0;

        x $hould # be # above 122;
        x $hould # be # at # most 124;

        x $hould # be # within (122,123);
        x $houldn't # be # within (1,3)

Other Caml News

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

Introducing vchan:

Welcome IPv6:

CamlGPC: An interface to Alan Murta's GPC Polygon Clipper:

GraphicsPDF: A version of Ocaml's Graphics module which outputs PDF:



How to review formalized mathematics:

Strange Datetime Problem:

Schoolboy Error:

OASIS website updated:

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