Previous week Up Next week


Here is the latest OCaml Weekly News, for the week of February 06 to 13, 2018.

  1. Catching type error in toplevel
  2. first release of bst: a bisector tree implementation
  3. Which XML libraries do you recommend?
  4. containers 2.0
  5. Exceptions vs Option
  6. Other OCaml News

Catching type error in toplevel


Weng Shiwei asked:
I am working on a grading script to grade students' submission. The general idea
currently is loading a submission file in toplevel and running testcases on many
functions in that submission file.

I choose toplevel is due to some functions in submission may have type error.
Saying one function in submission accepts only one argument but in fact it needs
two arguments. If I try compiling the submission together with grading code,
type error will stop the whole compiling. However, if I run it in toplevel, only
this testcases fail, and the following testcases can still run, which may give
them partial credits.

This is the background. My questions is:

- 1. Is it possible to catch type error in toplevel? If I could this, I can give
better feedback

- 2. Could some test framework like OUnit help? I admit using toplevel is
somewhat hacking. The tricky part is I have to be enough tolerable to submission
Gabriel Radanne replied:
You might want to look at the work done for the OCaml MOOC:
and [video](
- Hosted version and sources:

They do precisely what you describe (and quite a bit more, in fact).

first release of bst: a bisector tree implementation


Francois BERENGER announced:
A bisector tree allows to do fast but exact nearest neighbor searches in
any space provided that you have a metric (function) to measure the
distance between any two points in that space.

It also allows proximity queries, as in "all points within distance d
from my query point".

Cf. this article for details: "A Data Structure and an Algorithm for the
Nearest Point Problem"; Iraj Kalaranti and Gerard McDonald.

The code is here:

It might interest users of vantage point trees (minivpt, and vpt in
opam), kd-trees and such.
I think bst should be faster than vpt in most use cases.

It should appear in opam shortly.

Which XML libraries do you recommend?


Anton Bachin continued this thread:
For completeness, there is also
[]( It is focused on HTML5, but
it also includes an XML parser with the same interface.

I would recommend xmlm for most use cases.

containers 2.0


Simon Cruanes announced:
I'm happy to announce that Containers 2.0 is released and should land on opam

There were some improvements since the last
[announce]( The new
changelog is
However, the core of the changes is that dangerous polymorphic operators are
hidden after `open Containers`, and are not relied upon anymore.

There is a [migration
for updating your code to 2.0. In short, `open Pervasives` following `open
Containers` might ease the transition; printing functions are all named `pp`;
and some optional arguments are now mandatory.

Exceptions vs Option


Didier Wenzek said:
This recent post on
explores 4 ways to handle errors in OCaml. An interesting reading.

Other OCaml News

From the ocamlcore planet blog:
Here are links from many OCaml blogs aggregated at OCaml Planet,

OCamlPro’s Liquidity-lang demo at JFLA2018 – a smart-contract design language

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