Previous week Up Next week


Here is the latest Caml Weekly News, for the week of December 14 to 21, 2010.

  1. Atdgen/Biniou with support for cyclic values
  2. Other Caml News

Atdgen/Biniou with support for cyclic values


Martin Jambon announced:
Atdgen is a tool that produces OCaml serializers and deserializers from
type definitions in the ATD syntax.  Two serialization formats are
supported:  JSON and Biniou.  For more information on the project, see

The main highlight of this release (1.1.0) is support for sharing, which
allows the serialization of cyclic values such as graphs.  Sharing is
currently supported for the Biniou format only and requires extra
wrapping using type ref for non-record types.

The other new features are listed here:


$ cat cycle.atd
type shared_node = node shared (* sharing point *)

type node = {
 label : string;
 self : shared_node;

$ cat
open Cycle

let () =
 let rec a = { label = "A"; self = a } in
 let s = string_of_shared_node a in
 Printf.printf "%i %S\n" (String.length s) s;
 let a' = shared_node_of_string s in
 assert (a != a');
 assert (a == a.self);
 assert (a' == a'.self);
 print_endline "Success"

$ atdgen cycle.atd
$ ocamlfind opt -o test_cycle \
   graph.mli \
   -package atdgen -linkpkg
$ ./test_cycle
17 "\026\000\021\002\239\175\r\244\018\001A\204P\139\140\026\015"

Dissection of the serialized value:

 \026 shared_tag
 \000 0 indicates that the value follows

 \021 record_tag
 \002 field count
   \239\175\r\244 hash("label")
     \018 string_tag
     \001 string length
     A    string contents
   \204P\139\140 hash("self")
     \026 shared_tag
     \015 find value 15 bytes backward

The Biniou format is fully described here:

Home of each project:

Non-interactive installation with Godi:

$ godi_console update
$ godi_console perform -build godi-atdgen

Each of these four projects are distributed under a BSD license.

Biniou (c) 2010 Martin Jambon
Yojson (c) 2010 Martin Jambon
Atd (c) 2010 MyLife
Atdgen (c) 2010 MyLife

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

optimising texsearch : memory usage:

Tip: libguestfs API: Get the mounted device from a path:

Guest filesystem browser update 5:


Ruby is my work language:

OCurl cache manager:

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