Previous week Up Next week


Here is the latest Caml Weekly News, for the week of June 26 to July 03, 2012.

  1. Camllexer v1.1.1
  2. Quant position at LexiFi
  3. oasis v0.3.0: Architecture for building OCaml libraries and applications
  4. howto: recursively iterate over filesystem
  5. Other Caml News

Camllexer v1.1.1


Wojciech Meyer announced:
On behalf of Nicolas Pouillard, I'm happy that now Camllexer is
available as an Oasis package from [1]. The development version can be
found here [2]. The odb package manager shall be updated soon.


As read in the distribution's README file:

Camllexer is an enhanced lexer for Caml dialects.

The lexer has been extracted from the Camlp4 (> 3.10) lexer, which in
turns was reimplemented as a derivative of the lexer from the OCaml

This lexer has the following particularities:

* Correct and complete: as far as testing gone (~800_000 distinct
lines over ~3_000_000 lines of Caml like files).
* Supports most Caml dialects:
o By re-using the lexer of Camlp4 this lexer works on any
extension of the OCaml language made with Camlp4. In
particular it has a support for quotations and
o Works fine on lexers and parsers (ocamllex, ocamlyacc),
except when using the C style of comments.
* Lossless: every single bit of the input file is kept. Blanks,
comments, newlines, lexical conventions for writing literals, all
of it is kept in the returned token stream. Undesired information
can easily be thrown out of the stream.
* Keyword independent: there is no token for keywords. This is up to
you to cast some LIDENTs and some SYMBOLs into proper keyword
tokens of your own token type.
* Fault tolerant: errors take part of the token stream, allowing to
write fault tolerant translations.
* Flexible warnings: the lexer warn about some corner case of the
lexical conventions that the user might want to avoid, again
warnings take part of the token stream such that you easily
control everything.
* A simple lexer program is provided, it enables quick debugging,
and simple stream editions using Unix pipelines!

Quant position at LexiFi


Alain Frisch announced:
LexiFi is looking to expand its team of quantitative engineers,
working on pricing algorithms for financial products and related
stuff. This position includes a part of programming, in OCaml of
course, so this might be of interest for those in this community with
a background or an interest in numerical methods and finance.

More details on the job opening:
On LexiFi:

oasis v0.3.0: Architecture for building OCaml libraries and applications


Sylvain Le Gall announced:
A lot of changes, for this new release. 

Most important:

Fix bug with scanf %S@\n for ocaml 4.00. We were unfortunetaly using an
undocumented tolerance of Scanf in the previous version. You should
consider making new release using this version that fixed this. 

PACKAGES uploaded to oasis-db will be automatically "derived" before
OCaml 4.00 release (i.e. oUnit v1.1.1 will be regenerated with this new
version as oUnit v1.1.1~oasis1).

PACKAGES not uploaded to oasis-db need to be regenerated. In order not to 
break 3rd party tools that consider a tarball constant, I recommend to 
create a new version.

Thanks to INRIA OCaml team for synchronizing with us on this point.

Full article about this new release here:

Download it here:

The project:

OASIS generates a full configure, build and install system for your
application. It starts with a simple `_oasis` file at the toplevel of your
project and creates everything required.

It uses external tools like OCamlbuild and it can be considered as the glue
between various subsystems that do the job. It should support the following

- OCamlbuild
- OMake (todo)
- OCamlMakefile (todo),
- ocaml-autoconf (todo)

It also features a do-it-yourself command line invocation and an internal
configure/install scheme. Libraries are managed through findlib. It has been
tested on GNU Linux and Windows.

It also allows to have standard entry points and description. It helps to
integrates your libraries and software with third parties tools like GODI.


Get source code:
$ darcs get

Browse source code:;a=summary
Daniel Bünzli asked and Wojciech Meyer replied:
> Tried to remove the flag manually in 
> `~/.odb/install-type_conv/type_conv-108.00.01/` but it seems 
> that when I reissue `odb --unstable type_conv`, odb restarts everything 
> from scratch, download included.

You can simply reissue:

ocaml -build
ocaml -install

in ~/.odb/install-type_conv/type_conv-108.00.01/

that should work.

> There is `--get` that only downloads and extracts the package is there a 
> flag like `--no-get` to be able to start from that state in odb ?

at the moment I can't look into that, but I hardly can remember if
that was possible.
Edgar Friendly also replied:
At the moment, the way to have install a package from a local
directory is to add it to your packages file, like this:

type_conv dir=~/.odb/install-type_conv/type_conv-108.00.01

At the moment, odb allows the use of tarballs (http or local) on the
command line, but doesn't properly handle local directories. I'll see
if I can add support for this quickly.

howto: recursively iterate over filesystem


Ivan asked:
Are there any libraries that allow to walk through a filesystem (linux
filesystem in particular). At best I would like to find some library
that provides an ``iter'' function that will recursively iterate over
files and subdir in the given folder. At the very best, a library
resembling (by functionality) boost.filesystem will be very nice.
Rudi Grinberg suggeste:
Take a look here
under the heading: "Processing All Files in a Directory Recursively"
Stéphane Glondu also suggested:
Fabrice Le Fessant also suggested:
let rec iter_dir f dirname =
  let files = Sys.readdir dirname in
  Array.iter (fun file ->
     let file = Filename.concat dirname file in
     (f file : unit);
     if Sys.is_directory file then iter_dir f file
 ) files
Daniel Bünzli also suggested:
The book on Unix system programming in OCaml shows how to write a
`find` function.

But if you don't need tight control over the process and don't want to
link against the Unix module, just roll your own with the functions in

That's what I usually use (note that it does follow symlinks). 

   val fold_files_rec : string list -> ('a -> string -> 'a) -> 'a -> 'a
   (** [fold_files_rec dirs f acc] lists the files in [dirs], recursively
        in depth first order and folds the function [f] over the file names. *)

   let fold_files_rec dirs f acc = 
     let readdir d = try Array.to_list (Sys.readdir d) with Sys_error _ -> [] in
     let is_dir d = try Sys.is_directory d with Sys_error _ -> false in
     let rec loop f acc = function
     | (d :: ds) :: up -> 
        let files = List.rev (List.rev_map (Filename.concat d) (readdir d)) in
        let dirs, files = List.partition is_dir files in
        let acc = List.fold_left f acc files in 
        loop f acc (dirs :: ds :: up)
     | [] :: [] -> acc
     | [] :: up -> loop f acc up
     | _ -> assert false
     loop f acc (dirs :: []) 

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

Assessing Abstractions:

Oasis 0.3:

Camllexer 1.1:

The story of a stack overflow during Coq extraction:


2D Interpolation, Part 5: Final Optimizations:

Managing and Analyzing Big-Data in Genomics:

Syntax extensions without Camlp4: let's do it!:

OASIS v0.3.0 release:

Opa: Post 1.0 Status Update:

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