Previous week Up Next week


Here is the latest Caml Weekly News, for the week of September 25 to October 02, 2007.

  1. I'm looking for an OCaml book
  2. Ocaml for Scientific computing
  3. OCaml Reins 0.1 - Persistent Data Structure Library
  4. Camlp5 5.00
  5. LablGtk 2.10.0
  6. Weaktbl: a weak hash table library

I'm looking for an OCaml book


Continuing this thread, Xavier said and Mathias Kende answered:
> While developping OCaml-Java, I had to reverse-engineer this   
> information. 
> I produced two pdf files available at 
> downloads.html : 
>    - caml-formats.pdf describes both the marshalled data format and the   
> bytecode file format; 
>    - caml-instructions.pdf describes all the instructions used by the   
> OCaml VM. 

Thank you, this is exactly what I was looking for. Someone also gave a 
link to this page in an answer not forwarded to the list (I send it here 
for references): or

Ocaml for Scientific computing


Alex Mikhalev asked and Erik de Castro Lopo answered:
> I am wondering is anyone using Ocaml for scientific computing? 


> I didn't 
> mean parsing, but for number crunching applications, like signal/image 
> analysis. 

Yes. I'm working on code for audio digital signal processing and 
function optimisation. I also wrote my own simple computer algebra 

> Is it suitable for this kind of tasks in general? 

Much better than C or C++ or GNU Octave. 

> I have read "Ocaml for Scientists" and although it gave me some very 
> good ideas, I didn't manage to repeat a number of examples with modules 
> from this book. I had a problem compiling or using scientific modules 
> (lacaml, fftw, some others) on linux and macosx and since some of these 
> modules look like someones graduate project, 

I've looked at lacaml and didn't find any particular problems. The ocaml 
fftw module was a little more problematic but I resolved the problem in 
the end. 

 I would like to hear from 

> people practically using ocaml for mathematical simulations or analysis. 
> Preferable with OS, modules, problems encountered. 

I'm doing this on Ubuntu Linux, I usually use package distributed by 
Ubuntu but will compile my own from source if I need to.
Jon Harrop said:
> I've looked at lacaml and didn't find any particular problems. The ocaml 
> fftw module was a little more problematic but I resolved the problem in 
> the end. 

I found Christophe's latest version fftw3 from sourceforge CVS to be easier to 
use and very capable. One feature I would like is the ability to use ordinary 
float or Complex.t arrays rather than big arrays. I'd also like better 
integrated support for complex numbers in OCaml...
Hezekiah M. Carty answered the OP:
I am using OCaml for atmospheric/meteorological research.  I started 
using it about a year ago, and feel that it has been the right tool 
for the job.  My work so far has involved manipulating and analyzing 
satellite data sets.  OCaml has been quite fast computationally, and 
the strict type checking and type inference have helped to eliminate 
several sources of error. 

I've used the OCaml GSL bindings and toyed around with some of the 
plotting modules available (gnuplot, mlgrace, OVT, plplot, 
camlimages, the included Graphics module).  The code has been used 
and developed under Ubuntu, Debian and CentOS.  I currently use Godi 
for my OCaml installation because it makes it easier to keep things 
in my home directory if I don't have root access to a system. 

The biggest problem I've faced with OCaml has been missing 
libraries.  The data I'm working with is (almost) all in HDF format, 
so I had to write my own library bindings for OCaml.  The other is 
a library for plotting data - but that is largely due to a lack of 
time spent on my part.  That said, I've found writing bindings to C 
libraries in OCaml much nicer than other languages I've tried. 

An example of an older number crunching/scientific tool using OCaml 
is Psilab - 
However, it does not seem to be maintained by its author any more. 
I have updated the code slightly so that it builds with newer GCC 
versions if you have any interest in that. 

Good luck with your work!  I highly recommend OCaml, both for 
selfish reasons - to bring more number-crunching oriented users in 
to the community - and because it is an excellent tool for the job.
Jon Harrop answered and Markus E L said:
> > The biggest problem I've faced with OCaml has been missing 
> > libraries.  The data I'm working with is (almost) all in HDF format, 
> > so I had to write my own library bindings for OCaml.  The other is 
> > a library for plotting data... 

> While this is a general purpose graphics library rather than a plotting 
> library, you may be interested in our hardware-accelerated vector graphics 
> library Smoke: 


> Smoke makes it much easier to write visualization software. 

Nothing against Smoke, but on a Unix/Linux platform it might just be 
useful to use Ocaml to calculate the graphics data and pipe that to 
another process, e.g. one of the well known scientific visualization / 
graphing packages (starting with gnuplot, but there have been others 
too). For practical work (not advertising), that spares one to do all 
that tricky stuff like placing labels or ticks on the axis yourself. 

BTW: What I'd consider a boon for scientific visualization, actually, 
would be to output SVG to a file. Such an SVG file could be annotated 
with a usual graphics editor like inkscape for publication: Very 
valuable (if you don't need interactive visualization).
Jon Harrop answered the last point:
Absolutely. The full version of Smoke actually already does this but the free 
version does not.
Hezekiah M. Carty also answered this:
This is one of the things about the OCaml Visualization Toolkit 
(one of the Jane St. summer projects).  It is built around 
cairo-ocaml, which in turn supports SVG output. 

OVT is still somewhat incomplete, but its output is already quite 
attractive thanks to the Cairo backend.  SVG output is one of the 
items still missing from OVT, and I do not know what plans exist to 
maintain this library.  But with that addition it would be an 
immensely useful tool for scientific plots, among other things. 
I've already used OVT for a few simple presentation figures.
Mike Lin answered the OP:
I use it for a lot of genome sequence processing, comparative genomics 
and phylogenetic modeling. Algorithmically this involves conditional 
random fields (for which I have my own library) and some linear 
algebra and numerical optimization (for which I use Lacaml and 
ocamlgsl). I had a lot of frustrations at first, but it's been better 
since we got exception stack traces and ocaml+twt. 

For numerical computing, I wish ocamlopt would do at least basic loop 
optimizations, like hoisting invariant values -- this type of stuff is 
easily done manually, but often at the expense of code readability. I 
can see how this may be a bottomless pit for the dev team though, 
since I would probably always feel like we are one crucial 
optimization short of not having to rewrite that tight loop in C. 

In any case though, I work in a group where everyone else uses Python, 
so I'm already beating their pants off :o) 
Jan Kybic also answered the OP:
I have used Ocaml for several projects involving numerical 
calculations, including image processing, boundary element methods and 
optimization. I use Lacaml, fftw, MPI and Gsl libraries, the 
installation was not difficult.  Ocaml has performed very well for me 
so far, it is faster than Python or Matlab and more "friendly" than 
C/C++. Some minor issues: 

- There is too many different representations of vectors and matrices: 
  float arrays, plain big arrays, Lacaml Fortran style big arrays, 
  several kinds of Gsl vectors with yet separate styles. I found I 
  often had to convert vectors or matrices from one format to another 
  because the function I wanted to use was available for a different 

- Limited interactivity - it would help if you could call native compiled 
  modules from the toplevel. 

- Limited debugging - it is not possible to debug compiled modules. 
  I would like to see an interface to gdb (I work on Linux), or a 
  possibility for the byte compiled code being debugged to call 
  natively compiled modules. 

- I still find Ocaml object system less natural for me and more 
  limiting than for example Python's. Also, often you can do the same 
  thing with the objects as with the module system, so the choice of the 
  best design pattern is sometimes not obvious at the first sight and 
  requires a lot of foresight. But I assume this is just a matter of 

OCaml Reins 0.1 - Persistent Data Structure Library


Mike Furr announced:
I'm happy to announce the first source release of the OCaml Reins data 
structure library available at: 

This project started as an "OCaml Summer Project" and is now continuing 
its development on sourceforge.  The library already contains several 
implementations of persistent data structures and will continue to grow 
(possibly adding ephemeral data structures at some point if there's 

Features of this release include: 
   * List data types: 
      o Single linked lists (compatible with the standard library type) 
      o O(1) catenable lists 
      o Acyclic double linked lists 
      o Random access lists with O(1) hd/cons/tl and O(log n) 
   * Double ended queues 
   * Sets/Maps with both polymorphic and monomorphic keys/values 
      o AVL 
      o Red/Black 
      o Big-endian Patricia 
      o Splay 
   * Heaps: 
      o Binomial 
      o Skew Binomial 
   * Zipper style cursor interfaces 
   * Persistent, bi-directional, cursor based iterators (currently only 
     for lists and sets) 
   * All standard types hoisted into the module level (Int, Bool, etc...) 
   * A collection of functor combinators to minimize boilerplate 
     (e.g., constructing compare or to_string functions) 
   * Quickcheck testing framework 
      o Each structure provides a gen function that can generate a random 
        instance of itself 
   * Completely safe code. No -unsafe or references to Obj.* 
   * Consistent function signatures. For instance, all fold functions 
     take the accumulator in the same position. 
   * All operations use no more than O(log n) stack space (except for a 
     few operations on splay trees which currently have O(log n) expected 
     time, but O(n) worst case)
Mike Furr later added:
Several people emailed me about the problems with the LGPL and static 
linking.  So, I have released a new version (0.1a) whose only change is 
that it adds a linking exception to the LGPL in the exact same spirit of 
INRIA's own exception.
Later on in the thread, Daniel Bünzli said and Maxence Guesdon suggested:
> While I really like having a central repository and unification of   
> conventions I do like cherry-picking and embedding my modules.   
> Nevertheless I understand and respect your point, maybe it is a   
> matter of opinion/taste. But I'll explain why I like picking. 
> [...] 

You might be interested in caml-get:

Camlp5 5.00


Daniel de Rauglaudre announced:
New release of Camlp5. 
Version number is 5.00. 

Camlp5 is a preprocessor-pretty-printer of ocaml. 
It is compatible with OCaml versions from 3.08.1 to 3.11 included. 

Available at: 

Main changes: 
  - added 'q_ast.cmo' a quotation kit for syntax trees in user syntax 
  - ability to use IFDEF in constructors definitions and match cases 
  - many bug fixes and small improvements 
  - more documentation 

See file CHANGES for details. 

Warning: there are two modes, resulting two different Camlp5 installations: 
  - 'transitional' mode: the abstract syntax tree is compatible with 
      the previous version, but 'q_ast.cmo' is not usable. 
  - 'strict' mode: the abstract syntax tree is different and q_ast.cmo 
      can be used. 

The mode must be selected at configuration time (default = transitional). 
See the documentation.
Richard Jones asked and Daniel de Rauglaudre answered:
> 3.11? 

Yes: it is the version of the current OCaml sources under CVS.

LablGtk 2.10.0


Jacques Garrigue announced:
After close to two years of development, here is a new release 
of LablGtk2, the ocaml interface to the Gtk+2 GUI library and 
friends (glade, rsvg, gnomecanvas, gnomedruid, panel, gtkspell, 

This release is based on the gtk+-2.10.x series, hence the name. 
But it will work with older versions too. 

You can find it at: 

There is a (semi-)binary releases for windows, with glade and 
rsvg support, that can be used directly with the OCaml MSVC or mingw 
ports. ocamlopt is supported too. 

There are no major changes, but a number of bugs have been fixed, 
and some new widgets are interfaced (GtkMenuToolButton and 

The LablGtkSourceView code was contributed by Stefano Zacchiroli 
and Maxence Guesdon.

Weaktbl: a weak hash table library


Zheng Li announced:
I remember weak hash table was discussed on the list not long ago. I once ran 
into a situation where weak data structure was desired, and came up with this 
small module. Though I didn't really get a chance to make use of it (I turned 
to another solution laterly), I'd like to share and hope it would be useful to 

== Description == 

Weaktbl is yet another weak hash table library for OCaml. Its main features 

 * Both keys and associated values are weakly stored. A binding exists until 
   the key is no longer referenced anywhere 
 * The implementation is built upon the hash table functor of Weak library 
   rather than implemented from scratch, so it's rather small 
 * The interface is fully compatible with the standard Hashtbl library instead 
   of the hash sub-module of the Weak library, so basically you can also use it 
   as an alternative of the standard Hashtbl 
 * Its behaviors also follow the standard Hashtbl library's conventions. 
   E.g. the "binding orders" and the "current binding" concepts all make 
   sense here (with find/find_all/remove/replace/iter/fold etc.) 


Using folding to read the cwn in vim 6+

Here is a quick trick to help you read this CWN if you are viewing it using vim (version 6 or greater).

:set foldmethod=expr
:set foldexpr=getline(v:lnum)=~'^=\\{78}$'?'<1':1

If you know of a better way, please let me know.

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