Previous week Up Next week


Here is the latest Caml Weekly News, for the week of April 06 to 13, 2010.

Dedicated to Albertine, born on April 11.

  1. OASIS 0.1.0, ocamlify 0.0.1 and ocaml-data-notation 0.0.1
  2. Format: Fortran (&c.) style continuation lines?
  3. Ocaml-Pcre Documentation?
  4. Unicode solutions
  5. Other Caml News

OASIS 0.1.0, ocamlify 0.0.1 and ocaml-data-notation 0.0.1


Sylvain Le Gall announced:

This is the first public release of OASIS. It aims to provide a clean
and efficient way to create a configure/build and install system for
your OCaml applications and libraries using a single '_oasis' file.

It is inspired by Haskell's Cabal.

* generate a standalone which provides standard entry points in
* the build system,
* plugin system that allows to choose the best sub-system: OCamlbuild,
* custom build (Makefile based)...
* the file _oasis can be used as a metadata storage to help other tools
* analyze your source code
* customization of every piece of the generated build system by just
* editing the files concerned
* full OCaml script, no Unix call involved
* tested on Linux and Windows

Bonus features:
* available in french, using ocaml-gettext
* binary installers for Linux and Windows (32bits)


If you want to contribute:

ocamlify && ocaml-data-notation

These two tools are needed to build OASIS. They are released in separate
projects because I use it elsewhere and they are just pre-requisites of

ocamlify helps to include files as OCaml code. The beginning of a build
rule can be copy-and-pasted from OASIS;a=headblob;f=/

ocaml-data-notation, aka odn, dumps OCaml data in OCaml notation. It
is inspired by JSON. It uses type-conv to create data dumper functions,
you just have to add "with odn" in the type definition.  There is no
load scheme, since it is used to dump datastructure into OCaml scripts.
It is mainly a code generator helper.

Format: Fortran (&c.) style continuation lines?


Thorsten Ohl asked:
for ages, I've been using the following (somewhat hackish) approach to
pretty printing source code that requires special lexical markers to
allow statements that continue over more than one line.  (e.g. in

 foo = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 &
    + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 &
    + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 &
    + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 &
    + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 &
    + 1 + 1 + 1 + 1 + 1 + 1 + 1

and in /bin/sh we have the same with "\\" instead of "&"):

 open Format;;

 let continuing = ref true;;

 let wrap_newline () =
   let out, flush, newline, space = get_all_formatter_output_functions
   () in
   let newline' () =
     if !continuing then
       out " &" 0 2;
     newline () in
   set_all_formatter_output_functions out flush newline' space;;

 let nl () =
   continuing := false;
   print_newline ();
   continuing := true;;

 let _ =
   wrap_newline ();;

 (* Nonsensical example: *)
 for statement = 1 to 3 do
   printf "  @[<2>foo = 1";
   for i = 1 to 100 do
     printf "@, + 1"
   nl ()

The requirement to end each statement with "nl ()" is tedious in real
world applications and the use of the global variable "continuing"
violates my sense of aesthetics...

Is there a more idiomatic approach that I'm missing?
Martin Jambon then suggested:
Given the imperative nature of the Format module interface, your solution
seems right to me.  Maybe you'll output up to 2 bytes beyond the margin but I
guess that's ok.

You may also consider using easy-format, which offers a functional interface
on top of Format.  The programmer's job is to create a tree containing strings
and parameters while the actual printing is done by a single function call.
That said, easy-format does not support custom newline strings although I
could add the feature.  Link:

Ocaml-Pcre Documentation?


Oliver Bandel asked and Dario Teixeira replied:
> where can I find the documenatation to pcre-ocaml?
> Some pages seem to be out dated.
> Where can I find the docs?

The Ocaml library is essentially a very thin wrapper around the original
C library.  Therefore, all your documentation needs should be satisfied
by the original docs available at  I've used PCRE extensively,
and still haven't found one issue that wasn't covered in those docs...
Sebastien Mondet suggested:
For the ocaml part, I found this:
and this:
still quite useful.
Stefano Zacchiroli then said:
FWIW, in Debian (and derivatives) packages, ocamldoc API references are
consistently generated and made available under
/usr/share/doc/PKGNAME/html/api/, and also registered with doc-base.
Hence, you can usually browse all the HTML API references of installed
OCaml libraries with tools like dwww at

PCRE is no exception (PKGNAME = libpcre-ocaml-dev), even though it was
affected by ,
which got fixed a few minutes ago.

Unicode solutions


Jacques Carette asked:
I need to be able to lex/parse and pretty-print unicode with caml.

I am aware of several 'solutions' for each part, but I would choose to use
whatever library seamlessly allows me to both parse and build pretty-printers
for unicode-based input.

For example, it is unclear to me that module Print in Batteries integrates
well with UTF8.t - but that could just be a documentation issue. Camomile
seems to be good for the representation part, but does not seem to offer
lex/parse and pretty-print modules.

It seems like ulex + dypgen works for the front-end part.  Back-end?
[It's not clear to me that ulex + menhir works]
Dario Teixeira replied:
I can confirm that at least with a recent Menhir, you can use whichever lexer
you want, even Ulex.  In fact, I have used the Ulex+Menhir combination in a
couple of my own projects, and their source-code is available if you want
to check out how it's done:
François Pottier also replied:
> [It's not clear to me that ulex + menhir works]

Yes, it does. This is documented in the FAQ near the end of the Menhir
reference manual.

In short, although Menhir (like ocamlyacc) produces code whose interface
suggests that it is meant to be used with an ocamllex-generated lexer, this
interface can be easily adapted. Wrappers for this purpose are provided as
part of MenhirLib.

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

Someone’s feedback on OCaml:


OASIS 0.1.0 first public release:

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