Previous week Up Next week


Here is the latest Caml Weekly News, for the week of August 09 to 23, 2011.

  1. Piqi-0.5.6 released
  2. cppo 0.9.2 - cpp for OCaml
  3. Bolt 1.2 release
  4. Texexpand (and related tools) in OCaml
  5. llpp v7
  6. New release of the Caml Examples collection
  7. Parmap
  8. Zarith
  9. packing modules as a functor
  10. OpenGL ES for iPhone Simulator; working example app
  11. Other Caml News

Piqi-0.5.6 released


Anton Lavrik announced:
It is my pleasure to announce the new Piqi-0.5.6 release.

Piqi is a data serialization system for OCaml and Erlang. Starting
from this release, it supports 4 serialization formats: Google
Protocol Buffers, JSON, XML and Piq.

Some other new features include:

* An option to use OCaml arrays instead of lists for representing Piqi
lists and repeated fields.

* The ability to serialize arbitrary monomorphic OCaml types by
mapping them to already supported or defined Piqi types. This
mechanism can be used, for example, for serializing OCaml chars as
integers, bigints as decimal strings, or even "string
Map.Make(String).t" as list of {key, value} records.

* Support for “packed” binary encoding for primitive numeric types.
This is a compact encoding for representing repeated int, float or
bool values in Protocol Buffers.

* Windows builds using either Cygwin or MinGW.

Official announcement (it also includes links to examples):
Full changelog:

Your comments, suggestions and participation are welcome!

cppo 0.9.2 - cpp for OCaml


Martin Jambon announced:
I would like to announce the release of cppo 0.9.2 which contains a few
additional features since the last announcement in 2009.

cppo is a lightweight preprocessor analogous to cpp and compatible with
the OCaml syntax. It provides the classic directives #define, #include,
#ifdef, etc.


New features:

1. #ext directive: calling external preprocessors

1. #ext directive: calling external preprocessors

The new #ext directive allows to call an external command to process a
lines of input until #endext.

$ cat
let msg =
#ext rot13
  "BPnzy ehyrf!"

let () = print_endline msg

$ ocamlopt -o example1 \
  -pp "cppo -x rot13:\"tr '[a-zA-Z]' '[n-za-mN-ZA-M]'\""

$ ./example1
OCaml rules!


STRINGIFY allows to build string literals from unquoted text. This is
useful for including source code in error messages. STRINGIFY(foo) is
the equivalent of #foo in cpp syntax.

CONCAT concatenates its two arguments into a single identifier.
CONCAT(a, b) is the equivalent of a ## b in cpp syntax.

Bolt 1.2 release


Xavier Clerc announced:
This post announces the 1.2 release of the Bolt project, whose goal is
to provide a comprehensive yet flexible logging framework for the
Objective Caml language.

Home page:

Main changes since 1.1:
  - update for Objective Caml 3.12.1
  - support for Daikon layout
  - enhanced support for Paje layout
  - file rotation can now be requested on signal reception (SIGHUP,
    SIGUSR1, or SIGUSR2) using the 'signal' key in the configuration file
  - syntax extension: possibility to use an identifier as the 'LOG' message
  - syntax extension: 'WITH' and 'EXN' as synonyms for respectively
  - some code factorization

Texexpand (and related tools) in OCaml


Roberto Di Cosmo announced:
        here is an OCaml rewriting of some useful LaTeX utilities: 
texexpand and texdepend.

This code was written in 2003, so it does not uses all of the latest
bells and whistles in our favourite programming language, but it is
already quite cleaner than the original C code, and comes with some
added goodies:

 - the -b option allows to include the .bbl file in your expanded
   output, which is useful for final version of papers for ACM, etc.

 - the -x option adds some extra information to the expanded file,
   that allows to "unexpand" the .tex file with the companion 
   texunexpand tool (in Perl, sigh...)

Project home:

To compile and install:

 git clone git://
 make install

llpp v7


malc announced:
New version of llpp is now available (tagged v7) at


llpp a graphical PDF viewer which aims to superficially resemble

Changes (relative to v5):

* Human readable/editable configuration file
* Optional (default on) proportional display (for documents with variable
  width pages)
* Better pixmap cache
* Bird's eye (aka thumbnail) mode
* Help and info/setup modes (accessible by pressing 'h' and 'i' respectively)
* UI font handling was redone, i.e. Glut bitmap character API was
  replaced with Tor Andersson's glfont

   * bitmap characters are very very slow
   * the coverage of builtin fixed/helvetica/courier/times is tiny, so
     that not even cyrillic is visible in outlines
   * bitmaps live in their special raster world in OpenGL
   * bitmaps can not be made antialiased (glfont can be made aliased
     should there be a need)

* Tweaks all over the place (autoscrolling/zooming/user defined knobs/etc)

This version is known to work on Linux(ppc/x86_64), FreeBSD (Juergen
Lock), Mac OS X(x86_64). It used to work on Mac OS X/ppc[32|64] and
Windows XP(i386)/Vista (x86_64) in the past, but wasn't tested there
in a while.

OS X and Windows are second class citizens though.

Build instructions:


New release of the Caml Examples collection


Pierre Weis announced:
The Caml Examples package is a large set of Caml example programs.
Most of the programs are provided both in Objective Caml and in Caml Light.

This new enhanced version of the Caml Examples package contains the complete
set of examples from the book ``Le langage Caml'' in Objective Caml (and
obviously also in Caml Light).

You will also find numerous examples of GUI programs, in addition to a
collection of games such as ``Le solitaire'', ``Sudoku'', ``Hanoi'',
``Showsort'', ``KB'' ...

The package home page is at

The tar balls are available here:

All constructive criticisms and propositions are warmly welcomed.



Roberto Di Cosmo announced:
Dear all,
       a few lines to announce the availability of a minimalistic library 
can be useful to exploit your multicore processor with minimal modifications 
your OCaml programs.

In a nutshell

If you want to use your many cores to accelerate an operation which happens to
be a map, fold or map/fold (map-reduce), just use Parmap's parmap, parfold and
parmapfold primitives in place of the standard and friends, and 
the number of subprocesses to use by the optional parameter ncores.

For example, in the classical Mandelbrot example present in the example 
the line 

        Parmap.parmap pixel tasks ~ncores:i

allows to spawn i separate processes, each working on 1/ith of the list tasks.


The principle of Parmap is very simple: when you call one of the three 
primitives, map, fold, and  mapfold , your OCaml  sequential program forks  
in n
subprocesses (you choose the n), and each subprocess performs the computation 
the  1/n of the data, returing  the results through a  shared memory area to 
parent process, that resumes  execution once all  the children  have 
and the data has been recollected.

This means that you *must* run your program on a *single* multicore machine.
Repeat after us: Parmap is not meant to run on a cluster, see one of the many
available (re)implementations of the map-reduce schema for that.

By forking the parent process  on a sigle  machine, the children get access, 
free, to all the data structures already built, even the imperative ones, and 
far as your computation  inside the map/fold  does not produce side effects 
need  to be  preserved, the  final result will   be the same  as  performing 
sequential operation, the only difference is that you might get it faster.

Of course, if you happen  to have open  channels, or files, or other 
that should only be  used by the parent  process, your program  may behave in 
very wierd way: as an example, *do  not* open a  graphic window before 
calling a
Parmap primitive, and   *do   not*  use  this  library   if  your  program    

The OCaml code is quite simple and does not rely on any  external C library: 
the magic is done by your operating system's fork and memory mapping 
One could gain some speed by implementing a marshal/unmarshal operation 
on bigarrays, but we did not do this yet.

How to get it

Project home:

To compile and install:

 git clone git://
 make install


-- Marco Danelutto and Roberto Di Cosmo

P.S.: special thanks to Pierre Chambart for useful discussions on this code



Xavier Leroy announced:
It is my pleasure to announce release 1.0 of Zarith, a new OCaml
library for exact, arbitrary-precision arithmetic on integers and
rationals.  Zarith was written by Antoine Miné with a little help from
me and feedback from Pascal Cuoq.

To download:

The implementation uses GMP (the GNU Multiple Precision arithmetic
library) to compute over big integers.  However, small integers are
represented as unboxed Caml integers, to save space and improve
performance. Big integers are allocated in the Caml heap, bypassing
GMP's memory management and achieving better GC behavior than e.g.
the MLGMP library.  Computations on small integers use a special,
faster path (coded in assembly for some platforms and functions)
eschewing calls to GMP, while computations on large intergers use the
low-level MPN functions from GMP.  As a consequence, Zarith is much
faster and more space-efficient than the Big_int module from OCaml's
standard distribution.

Additional niceties of Zarith include:
- short function names and infix operators, allowing one to write e.g.
    Z.(~$2 + ~$5 * x)
- polymorphic comparisons (=, <, >, etc) work correctly on Zarith's
  big integers, provided OCaml 3.12.1 or later is used.

Feedback is welcome, preferably through the bug tracker at
rixed asked and Gerd Stolpmann replied:
> Is there anything special in 3.12.1 to help library authors define
> specialized comparison operators ?

You can define such operators for abstract values only (i.e. on the C
side of bindings), and this is available for a long time. There is no
such feature for data structures entirely programmed in OCaml (which is
a bit self-discriminating, IMHO).

I guess the problem is that any addition of comparison operators
requires another level of indirection, and it would feel strange to
program and use. This means one could imagine with minimal modifications
of the current runtime to support something like

type 'a wrapped_value
val wrap_value : 'a comparison_operators -> 'a -> 'a wrapped_value
val unwrap_value : 'a wrapped_value -> 'a

In the machine representation, a wrapped_value would have a special tag
to signal the runtime that it carries comparison operators. Because of
this indirection, it is inconvenient to use, as the programmer of a data
structure would need to wrap and unwrap values just to override the
comparisons (basically like it is possible in C today). One idea to
improve this could be a special kind of functor that is able to add
wrap/unwrap calls to a given argument module, so the programmer would
not have to program this explicitly.
Gabriel Scherer also replied:
Yes, from the 3.12.1 changelog:
> - Added new operation 'compare_ext' to custom blocks, called when
>  comparing a custom block value with an unboxed integer.

The  following fix is also possibly relevant:
> - Hardened generic comparison in the case where two custom blocks
>  are compared and have different sets of custom operations.

I believe the comparison hardening was made desirable by the expected
use of first-class modules to encode existential datatypes: with
existential datatypes you may try to use the polymorphic comparison
operators on two values of the same (existential) datatype having
different internal representations. The problem didn't happen with the
previous encoding of existential types using first-class polymorphism,
as it implies packing the value inside closures, so the polymorphic
comparison operators were not usable.
Alain Frisch then added:
The problem existed before, because of exceptions. When two exception
values having constructors with the same name are compared with the
polymorphic equality, their arguments are compared structurally even
if they don't have the same type. (One way to address this would be to
have a special tag on exception values to force physical comparison of
the constructors.)

packing modules as a functor


Fabrice Le Fessant announced:
  We have recently worked on the OCaml compiler to allow packing
compilation units inside a functor. This work extends the current -pack
option with a new -pack-functor option, that will generate a compilation
unit, containing a functor composed of independent compilation units
(compiled with a new -functor option).

  As we are looking for feedback on the utility of this feature, we have
written a small page to release the patch and describe how to use it:

  There are also two additional features in the patch: (1) you can use
-i on interface files (.cmi) instead of only sources, and (2) you can
use -pack to generate an interface file (.cmi) from other interface files.

  The page has also a link to "ocp-pack", a simple program to pack
sources instead of compilation units, to achieve the same result as the
-pack and -pack-functor options. Note that, if you have recursive
dependencies between compilation units (usually achieved by hidden
dependencies between abstract types), you will need a patched OCaml to
be able to compile the new source (the patch is also provided).

OpenGL ES for iPhone Simulator; working example app


Jeffrey Scofield announced:
A while back I modified LablGL to work with OpenGL ES 1.1, calling my
modified version LablGLES.  Just recently I got LablGLES working in the
iPhone Simulator, which I've found to be a nice prototyping environment
for iOS projects.

I also made an example LablGLES app that works on both the iPhone
Simulator and the iPhone itself.  It's called IcosaBlue, since it
displays a rotating blue icosahedron.  It's very simple, but it's a
complete example of an OpenGL ES iPhone app coded in OCaml.

For those interested in trying OpenGL ES on iPhone and the iPhone
Simulator, I've released sources and binaries for everything.  Here are
some links:

  [LablGLES, OpenGL ES for iPhone and iPhone Simulator][1]
  [IcosaBlue, rotating blue icosahedron using LablGLES][2]
  [General page of OCaml-on-iOS resources][3]
  [Home of LablGL, OCaml OpenGL interface by Jacques Garrigue][4]

I'd be happy to hear from anybody interested in OCaml on iOS.

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

Putting it all together: PubSub for OCaml with Coherence:

Zarith 1.0 released:

Coq Programming with Subsets:

ocaml sqlite3 date:

more on precise date on ocaml:

Queries in Coherence with OCaml:

Bolt: 1.2:

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