Previous week Up Next week


Here is the latest Caml Weekly News, for the week of August 21 to 28, 2012.

  1. Lablwebkit 1.8.2
  2. OCaml app in the Mac App Store
  3. State of Saffire or other FFI-checkers
  4. Companies using OCaml
  5. LablGtk 2.16.0
  6. Is there a printer for ocaml's parsetree
  7. Thread-private data in C stubs
  8. Other Caml News

Lablwebkit 1.8.2


Adrien Nader announced:
I am happy to announce the 1.8.2 release of lablwebkit which is a
binding to the corresponding webkit-gtk version. Almost all of its API
besides the DOM-related function is handled.

This new version is an update to the new webkit-gtk API and doesn't
introduce other changes.

The bindings are generated automatically by cowboy[1] and its support
for glib2-based libraries.

You can download the source at:


OCaml app in the Mac App Store


John Whitington announced:
Our PDF Editor, mostly written in OCaml, is now in the mac app store:

There weren't any problems with sandboxing, developer-signing or app
store approval for an executable with OCaml code in it.

State of Saffire or other FFI-checkers


Adrien Nader asked:
I regularly stumble on Saffire which is an FFI-checker. Its webpage is
dead but still accessible (along with a release tarball) through

I've fixed the build system a bit but it seems to be missing a module
named "MLast" and I'm quite obviously stuck on that.

Has anyone updated saffire? Or has build sources that work? Or something at 

Or are there other checkers?
After several replies, Adrien announced:
I've created a project on the OCaml forge for Saffire:

I've commited several fixes so far but it's not building yet.

Right now, building yields the following error:
File "src/ext/ffi/", line 208, characters 8-35:
Error: Unbound constructor MLast.RfTag

I've checked in all the camlp5 releases and none of them mentions
RfTag; only 4 commits in the ocaml sources mention it and I couldn't
see any documentation about it (saffire was built against ocaml 3.08).
Also, unfortunately, I don't know camlp5.

If you're interested in Saffire, you can become a commiter or simply
submit patches. The work to simply see which results it can bring is
probably minimal; it it proves useful in practice, there can also be
more work (like maybe using bin-annot instead of being a wrapper
around ocaml{c,opt} and using camlp4).

Companies using OCaml


Continuing the thread from last week, Paolo Donadeo said:
Sorry, I completely missed this thread. For what it's worth, you can
add Italy, and Studio Associato 4Sigma:

We are a small firm and we make web sites (90% of our work) and some
interesting web application (10%). OCaml is not our main language but
is used here and there, and I wrote a small server that is a key
component of a service we offer our customers.
David Baelde also said:
I have a few observations that may be relevant for your "company" or
"success" pages.

First, Nicolas Cannasse (main developper of HaXe) has recently left
Motion Twin for another French company, Shiro Games
( I'm not sure that Motion Twin still counts
as a user of OCaml, it seems possible that they are now only using the
HaXe compiler, whose development would have followed Cannasse at Shiro

Second, I think that liquidsoap ( should be added
to the list of successes. As a main developer of the project, I am not
neutral, but I believe that our tool is clearly well established in
the (internet) radio industry. Liquidsoap is well known as a tool with
unique abilities, and has lots of users including big commercial ones.
It is not developed as a business, but companies develop services or
software on top of it. For example, Sourcefabric develops and sells
Airtime on top of liquidsoap -- but they may not be relevant for your
company page because they don't write OCaml code.

I think those two examples are interesting in that they are outside of
the traditional formal methods and scientific computing fields. If you
want to include paragraphs about them in one of your pages, I can

In my opinion, these examples together with Gerd's remark show that
the company page should have some sort of disclaimer, pointing out
that the listing does not mention companies using products based on
OCaml, and does not mention companies which don't advertise their use
of OCaml. The success page does not have that problem.

LablGtk 2.16.0


Jacques Garrigue announced:
At long last, here comes LablGtk 2.16.0, the latest release of the
OCaml interface to the Gtk+ GUI library and friends (gtkglarea, glade,
rsvg, gnomecanvas, gnomedruid, panel, gtkspell and gtksourceview2.)

It includes a number of bug fixes, API improvements, and better thread

You can find it at:

A binary release for windows is included, using OCaml 4.00.

Many people contributed to this release, see the commit log for all
their names...

Jacques Garrigue Nagoya University garrigue at

Changes since 2.14.2:

2012.08.23 [Jacques]
* update Windows port, compiles fine on mingw with
./configure --disable-gtktest
* lablgtk2 script does not load extra libraries by default
(use flag -all to load all extensions)

2012.08.17 [Jacques]
* generate correct lablgtk2 script for findlib.
* add old-uninstall target.
* support threaded toplevel with Quartz backend, using
(runs the toplevel loop in another thread)
* remove GtkThInit from META (not portable)
* avoid busy waiting by using g_main_context_set_poll_func to
make polling non-blocking.
busy waiting is still needed for VM threads, and can be activated
by setting the environment variable LABLGTK_BUSY_WAIT.

2012.08.16 [Jacques]
* update applications/browser for OCaml 4.00
* update applications/camlirc to use GText instead of GBroken.text

2012.07.26 [Pierre-Marie]
* improvements to GtkSourceView2.
* add cast and assignation functions to GText.nocopy_iter.
* add Gtk 2.10 missing key modifiers.

2012.07.24 [Jacques]
* can still install using old-install.

2012.06.19 [Adrien]
* add a high-level API to create keyboard shortcuts.

2012.06.12 [Adrien]
* add several #as_foo methods: entry, notebook, range
* new signals for notebook: select_page, reorder_tab,
change_current_page, move_focus_out, page_{added,removed,reordered}
* add gtk_container_child_{set,get}_property
* add gtk_notebook_{set,get}_tab_reorderable
* add gtk_signal_new which can be used to create custom keyboard shortcuts
* add g_signal_list and g_signal_query
* add functions to connect to notify::foo signals which indicate when an
object property changes
* add foo#connect#notify_bar methods to add callbacks on changes of
the "bar" property of the object "foo".

2012.04.11 [Maxence]
* use findlib to install (see README for the list of installed packages)

2012.06.05 [Jacques]
* merge GtkSourceView2 additions by Pierre-Marie Pedrot

2012.03.07 [Jacques]
* add Make_Val_option to wrappers.h

2011.07.20 [Jacques]
* add gtk_accelerator_name/get_label (for Pierre Boutillier)
* add gtk_accel_map_foreach/change_entry (ibid)
* add gdk_window_clear_area (for DDR)
* make gtk_tree_view_get_visible_range version dependent (Thomas Ripoche)

Is there a printer for ocaml's parsetree


Hongbo Zhang asked and Alain Frisch replied:
> Is there any printer for ocaml's parsetree, I mean when you print
> the parsetree, the textual output can be fed to the ocaml's compiler again.
> I took a look at the ocaml's source tree, the built-in printer for
> ocaml's parsetree seems to be only for debugging purpose.

There is a printer in tools/ It would be useful to
integrate it to the ocaml compilers, with an option to tell them to
dump the (preprocessed) parsetree in source form.

> Alain, when you do Ast-Rewriter, how do you visualize the output if you
> don't have a printer for ocaml's parsetree?

Currently, I use -dparsetree when I need to debug some ast rewriter

Thread-private data in C stubs


Andre Nathan asked, and later replied to himself:
> I'm writing stubs to a C library uses pthreads and exposes two functions
> to get and set thread-private data, getpriv(ctx) and setpriv(ctx, p)
> where ctx is some opaque context object, and p is a void* pointer.
> What's the best way to deal with this from the stub code, ie., how do I
> avoid the thread-private data to be garbage collected when the OCaml
> variable goes out of scope?
> Since the library in question uses threads internally, this needs to be
> a thread-safe solution.

For the record, with help from #ocaml, I got it to work like this:

struct priv {
value v;

CAMLprim value
caml_setpriv(value ctx_val, value priv_val)
CAMLparam2(ctx_val, priv_val);
context *ctx = (context *)ctx_val;
struct priv *p;

p = getpriv(ctx);
if (p != NULL) {

p = caml_stat_alloc(sizeof(*p));
p->v = priv_val;
ret = setpriv(ctx, p);

Jonathan then said:
Dear Andre, in my view it is needlessly inefficient to create a new global 
root for every item which crosses the C-interface. I used a system which uses 
dlmalloc to carve up an allocated caml custom block into convenient sized 
chunks. Each of these large blocks could be a local root or they could be 
chained together from one global root. Another advantage is that subroutines 
written in C that allocate memory do not need to know they are running under 
caml if dlmalloc is compiled to replace the system malloc. The one downside 
is that it is difficult to track when the global blocks are ready to be 
released. My impression is ocaml runtime would get very slow if there were 
huge numbers of global roots.

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

LablGTK2 2.16.0:

A hott thesis:


lablwebkit 1.8.2 released:

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