Previous week Up Next week


Here is the latest Caml Weekly News, for the week of March 20 to 27, 2007.

  1. ledit 1.13 + mlrogue 1.00
  2. One-year INRIA post-doctoral position
  3. wiki for libraries comparisons
  4. documentation for building C++ libraries with ocamlbuild
  5. [Camlp4 3.10] The rosetta stone

ledit 1.13 + mlrogue 1.00


Daniel de Rauglaudre announced:
New version 1.13 of ledit. Ledit is a text editor allowing to edit lines 
while using an interactive command (e.g. the ocaml toplevel). Change: Added 
option -u to allow using utf-8 encoding. 

New version 1.00 of mlrogue. MLrogue is a clone of rogue, a game of the 
80ies running in a terminal 24x80 (e.g. an xterm). Change: minor fixes 
and improvements. Work well after months of testing.

One-year INRIA post-doctoral position


Frederic Blanqui announced:
A one-year INRIA post-doctoral position is available: 

Title: Generation of construction functions guaranteeing algebraic invariants 
on concrete data types 

Aim: Although concrete data types are very useful in defining complex data 
structures, they are not always sufficient to adequately specify the data 
structures required by some algorithms. Often, only a subset of the concrete 
data type is in fact used since some invariants between the components are 
mandatory to ensure the correctness of the program. Now, many invariants can be 
described by using some equational theory. For instance, a sorted list is a 
particular representative of the equivalence class of lists modulo 
commutativity. The usual way to solve this problem is to use abstract data 
types or, better, private data types if one does not want to lose the ability 
of doing pattern matching. We propose to study the automatic generation of 
certified construction functions guaranteeing algebraic invariants on concrete 
data types, and develop an extension of OCaml with relational data types, that 
is, data types with invariants described by user defined equations. 

More information and online application on:

Competences and profile: The position involves research and development in the 
area of functional programming, rewriting theory (in particular Knuth-Bendix 
completion) and, possibly, interactive theorem proving (experience with a proof 
assistant such as Coq is welcome). Speaking french is not necessary. 

Requirements: Candidates are required to hold a PhD degree between May 2006 and 
June 2007. 

Salary: the monthly gross salary is approx. EUR 2,150. 

- laboratory: LORIA ( 
- team: Protheo ( 
- project: Quotient ( 
- location: Nancy, in the East of France is at 1:30 from Paris by tren, 1:30 
from Luxembourg airport by car, and 1:30 from Germany and Belgium. 

Application deadline: 1st July 2007. 

Contact: Frederic Blanqui ( 

More information about INRIA post-doctoral positions:

wiki for libraries comparisons


Jean-Baptiste Rouquier announced:
I just created (thanks to Christophe 
Raffalli for allowing me to reuse 
It seems to me that a wiki is more suitable than a mailing list for this 
kind of information sharing. 

Feel free to 
 - add you wishes on the list of needs to compare 
 - contribute to the pages (even small additions and corrections) 
 - argue that wikipedia would be better for this (and do the migration)

documentation for building C++ libraries with ocamlbuild


Christian Sternagel asked and Nicolas Pouillard answered:
> Is there some documentation or at least a tutorial for how to setup 
> ocamlbuild in order to build a lib<name>.a file from a bunch of *.c, *.C, 
> and *.h files? 

$ cat libfoo.clib 

$ ocamlbuild libfoo.a 

> And after having done that, how to tell ocamlbuild that some ocmal-program 
> which is build depends on lib<name>.a. 

$ cat _tags 
<myocamprog.{byte,native}: use_foo 
$ cat 
open Ocamlbuild_plugin;; 
open Command;; 
dispatch begin function 
| After_rules -> 
    flag ["ocaml"; "link"; "use_foo"] 
            (S[A"-cc"; A"g++"; A"-ccopt"; A"-Lfoo"; A"-custom"; 
A"-cclib"; A"-Ifoo"]); 
    dep ["ocaml"; "link"; "use_foo") ["libfoo.a"] 

Some `flag' declaration might be useful in order to tweak the C/C++ compilation.

[Camlp4 3.10] The rosetta stone


Martin Jambon asked and Nicolas Pouillard answered:
> I would like you or anyone knowledgeable to translate one significant 
> syntax extension. You know, some kind of Rosetta stone. You can take 
> Markus' sexp syntax extension or ioxml if you prefer, it won't be much 
> different. 

Here is your rosetta stone :) 
I translated 

To highlight a little the changes in the AST, 
I want to show an input snippet and two translations: 

For the old camlp4 it was: 

| Object l -> 
   let ml = (fun x -> (x.field_caml_name, 
                                convert x.field_type)) l in 
   <:ctyp< < $list:ml$ > >> 

The type of `ml' is (string * ctyp) list. The concept of quotations is 
to get concrete syntax for abstract terms and then avoid to learn all 
constructors and types. Alas for some of them you have to know the type. 
In the new version you can express any term (except one) by concrete syntax. 

The closest version is: 

| Object l -> 
   let ml = (fun x -> 
     <:ctyp< $lid:x.field_caml_name$ : $convert x.field_type$ >>) l in 
   <:ctyp< < $list:ml$ > >> 

Here one doesn't know if methods declarations are a pair or something else and 
we don't care. Since one knows the syntax << method_name : method_type >>. 
At this place the list antiquotation $list:ml$ is a sugar for 
$Ast.tySem_of_list ml$. 

By changing a little more the code one can use something closer to the 
object syntax. 

| Object l -> 
   let ml = List.fold_right (fun x acc -> 
     <:ctyp< $lid:x.field_caml_name$ : $convert x.field_type$ ; $acc$ >>) 
     l <:ctyp<>> in 
   <:ctyp< < $ml$ > >> 

The general syntax of object types (omiting `..' for the row variable) is 
< meth1 : type1 ; ... ; methN : typeN > then one can avoid to construct a list 
(since map is a fold_right with `::') and then call a function that destruct it. 

Another thing to point out is the use of the nil type <:ctyp<>> that is quite 
useful to start the folding. 

In this translation I used both styles depending of the context. 

The patch:

The new version (compiles with camlp4orf):

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}$'?'&lt;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