Features Download
From: Alan Schmitt <alan.schmitt-o/5/jSaJEHk+NdeTPqioyti2O/JbrIOy <at> public.gmane.org>
Subject: Attn: Development Editor, Latest Caml Weekly News
Newsgroups: gmane.comp.lang.ocaml.weekly-news
Date: Tuesday 10th July 2012 15:39:24 UTC (over 4 years ago)

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

1) ocaml top-level line editing script
2) ReML, a library for combinatorics
3) google-drive-ocamlfuse 0.1-pre2
4) Agda-style parser
5) 4.00.0 is coming
6) stream parsers with location information?
7) pretty-printing with camlp4?
8) ocaml-safepass 1.0
9) file specific outputting
10) Other Caml News

1) ocaml top-level line editing script
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2012-07/msg00032.html>
** Aaron Bohannon announced:

One thing that is missing from the OCaml top level loop is line
editing features. I used to use a wrapper program called "ledit" that
added readline support, but I never seem to have it installed on my
machine when I need it, and moreover, I have started to get used to
the more flexible line editing of zsh.

After some poking around, I found that it's fairly straightforward to
wrap any REPL with a zsh script and get zsh line editing capabilities,
which includes multi-line support (e.g., so you can fix a typo you
made three lines back).

I'm attaching the script I hacked together, in case it is useful to
anyone else. It works great for me, but it was not written to be
generic and robust, so YMMV. You must use ctrl-D to exit cleanly -- I
didn't bother adding support for "#quit". I'm sure someone could make
many improvements to it if they had more patience for zsh scripting
than I do.

(Find the file at the archive link above.)
** Markus Weißmann suggested:

rlwrap? [1] Its probably already available through your favorite package


[1] <http://utopia.knoware.nl/~hlub/uck/rlwrap/>
** rixed added:

Interesting, although rlwrap gives you history, filename completion,
prompt coloring, syntax completion, brackets matching, use of an
external editor and easy configuration via .inputrc.

For instance I have this in my .zshrc:

alias ocaml='rlwrap --prompt-colour=green --multi-line --remember 
--complete-filenames --command-name=ocaml ocaml -rectypes'

And this in my .inputrc:

$if ocaml
"\C-o": "()\C-b"
"\C-n": ";;\n"

While the default C-^ launches vi (for multi-line edits)
2) ReML, a library for combinatorics
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2012-07/msg00039.html>
** Jean-Christophe Filliâtre announced:

This is our pleasure to announce the first release of ReML, an OCaml
library for combinatorics.

This library provides the following modules:
- Dlx: Knuth's dancing links
- Zdd: Zero-suppressed binary decision diagrams
- Emc: a common interface to modules Dlx and Zdd to solve the Exact
  Matrix Cover problem
- Tiling: converts a 2D tiling problem into an EMC problem

Documentation: <http://www.lri.fr/~filliatr/reml/doc/index.html>

ReML also contains an interpreter for a language to describe 2D tiling
problems (such as Pentominos) and to solve them or to enumerate their
solutions. The source tarball contains some examples.

Web page: <http://www.lri.fr/~filliatr/reml/>
3) google-drive-ocamlfuse 0.1-pre2
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2012-07/msg00040.html>
** Alessandro Strada announced:

I'm developing a FUSE filesystem over Google Drive using ocamlfuse.
The project is hosted on OCaml Forge
and on github
I've also
uploaded the package on oasis-db

In this pre-release, I've implemented enough FUSE operations to
provide a read-only access to the files stored on Google Drive. Before
implementing the write operations, I would like to have some feedback
from real users to see if someone finds this project useful and to
check if my implementation is working. I've set up a mailing list on
the forge (<https://lists.forge.ocamlcore.org/cgi-bin/listinfo/gdfuse-devel>)
where you can post questions, suggestions or report problems. Or, if
you want, you can open issues on github.

Before trying this application, please read the wiki pages containing
info about authorization
and configuration
** Goswin von Brederlow suggested:

You can use my fuse bindings for ocaml:

4) Agda-style parser
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2012-07/msg00042.html>
** Andrej Bauer asked and Gabriel Scherer replied:

> If I wanted a parser in Ocaml that can parse things in the style of
> Agda (with the cool underscore thingy), where would I start looking?

My advice would be to mimic Agda's conceptual two-pass process: parse
only the static Context-Free Language structure of your language,
parsing "expressions" (or any syntactic class that admits mixfixes)
into just a list of non-terminals (plus parenthesing, if you assume
your mixfixes are all well-balanced wrt. symmetric delimitors). This
can be done easily with existing OCaml parser or parser generator
technology (menhir). Then, in a later pass, you compute mixfix
definitions/scopes and add this structure to the parsetree, using a
custom algorithm that has been described in the Agda literature (or
non-Agda previous work), eg.

This is a clean way to handle this and, I believe, one of the simplest
to use, understand and debug.
** Jérémie Dimino also suggested:

You can have a look at dypgen [1]. Actions can extend the grammar.

[1] <http://dypgen.free.fr/>
5) 4.00.0 is coming
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2012-07/msg00043.html>
** Damien Doligez announced:

We are in the last stages of fixing bugs before 4.00.0 is released.
If your favorite bug report is still open and you want to know
whether we will fix it before 4.00.0, look at its "Target Version"
field. If this is 4.00.0+dev, we are trying hard to fix your bug.
If it is not and you want to insist that we fix your bug before
the release, just drop me a note. I'm not making any promise,
but we will carefully review your bug before taking a decision.
6) stream parsers with location information?
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2012-07/msg00056.html>
** Nicolas Ojeda Bar asked and Gabriel Scherer replied:

> Is there a clean way to use stream parsers/lexers if I want to have
> location (line number, character position) information attached to
> each token?

Indeed: you need your lexer to produce location information. Instead
of manipulating a (token Stream.t), you will produce (and then parse
at the lexer level) a ((token * location) Stream.t).

This is the way Camlp4 parsers are implemented (recursive descent over
a stream of tokens and positions). See also "Planck", an experiment at
combinator parser libraries by Jun Furuse, using a similar (but
different) architecture.

7) pretty-printing with camlp4?
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2012-07/msg00058.html>
** Nicolas Ojeda Bar asked and Gabriel Scherer replied:

> Is it possible to use Camlp4 to write pretty printers of arbitrary
> data? The signature Camlp4.Sig.Printer seems to indicate the pretty
> printing facility only works with OCaml ASTs...
> On the other hand, with Camlp5 it is possible to write pretty
> printers for arbitrary ASTs
> (see <http://pauillac.inria.fr/~ddr/camlp5/doc/html/printers.html>),
> so I imagine there must be a way to do the same thing with Camlp4...

As far as I know, no such facility exists in Camlp4.

Note however that there is quite a difference between parsers and
printers. Supporting extensible parsing is very difficult, because
parsing is quite a complex process. On the contrary, "printers" as
presented here or as implemented in Camlp4 are more like regular tree
traversals, calling a pretty-printing library that takes care of the
visual formatting aspects. An "extensible printer" can therefore be
summarized as an extensible tree traversal, something that is not too
difficult to achieve with a decent software architecture; for example
Camlp4's MapGenerator framework.

If you don't need the "extensible" parts of Camlp5 printer's support,
because your datatype to print is fixed, you can use the
pretty-printing library directly. Camlp4 uses the Format module of the
standard library, but I personally found it to be a bit painful to
use, and have a preference for the Pprint library of François Pottier:

(There are other pretty-printing libraries for OCaml that I haven't
tried, such as Martin Jambon's easy-format:

My advice would be to use one of those pretty-printing libraries, to
see if it fits your bill, or if you really need another abstraction
layer such as Camlp5 printers.
(Of course you can also use Camlp5 directly if it solves you problem.)
8) ocaml-safepass 1.0
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2012-07/msg00066.html>
** Dario Teixeira announced:

The registration of users with login + password is a common feature in 
web sites.  And as you know, this login data is a valuable prize for
attackers.  Therefore I'm happy to announce the availability of version
1.0 of OCaml-safepass, a simple library offering facilities for the safe
storage of user passwords.  By "safe" I mean that passwords are salted
and hashed using the Bcrypt algorithm [1].  Salting prevents rainbow-table
based attacks [2], whereas hashing by a very time-consuming algorithm such
as Bcrypt renders brute-force password cracking impractical.

OCaml-safepass's obvious usage domain are web applications, though it
does not depend on any particular framework.  Internally, OCaml-safepass
binds to the C routines from Openwall's Crypt_blowfish [3].  However,
it would be incorrect to describe OCaml-safepass as an OCaml binding
to Crypt_blowfish, because the API it exposes is higher-level and more
compact than that offered by Crypt_blowfish.  Moreover, OCaml-safepass's
API takes advantage of OCaml's type-system to make usage mistakes nearly

Here is the project website:

The API documentation is also available on online:

Feedback is more than welcome!
Best regards,
Dario Teixeira

[1] <http://en.wikipedia.org/wiki/Bcrypt>
[2] <http://en.wikipedia.org/wiki/Rainbow_table>
[3] <http://www.openwall.com/crypt/>
9) file specific outputting
Archive: <https://sympa.inria.fr/sympa/arc/caml-list/2012-07/msg00069.html>
** Dash, Santanu asked and Jérémie Dimino replied:

> I work in the area of program analysis. I am currently trying to analyse 
> Ocaml programs and wish to output file-specific information with the aid
> the Ocaml compiler.
> For example, if I compile a file called foo.ml, i want to output a file 
> called foo.info based on an analysis of alpha.ml. I have already
> the analysis module with the Ocaml compiler.
> Can someone direct me on the best way to go about this? Is there a
> in the compiler that stores the filename of the file currently being

There is Location.input_name. It is set by the compiler before parsing
a source file (file "driver/pparse.ml", function "file"). Note that if
there are multiple source files on the command line it will be
modified for each one of them.
10) Other Caml News
** From the ocamlcore planet blog:

Thanks to Alp Mestan, we now include in the Caml Weekly News the links to
recent posts from the ocamlcore planet blog at <http://planet.ocamlcore.org/>.

Existential Crisis:

Half-hearted hash table:

PG'OCaml 1.6 released:

Opa 1.0.4 Released:

Major change soon...:
Old cwn

If you happen to miss a CWN, you can send me a message
([email protected]) and I'll
mail it to you, or go take a look at
the archive (<http://alan.petitepomme.net/cwn/>)
or the RSS feed of the
archives (<http://alan.petitepomme.net/cwn/cwn.rss>).
If you also wish
to receive it every week by mail, you may subscribe online at

CD: 4ms