Previous week Up Next week


Here is the latest Caml Weekly News, for the week of 12 to 19 July, 2005.

  1. pftdbns 0.2.6
  2. AS/Xcaml status
  3. Pattern Matching Papers
  4. OMake 0.9.6
  5. Idea for another type safe PostgreSQL interface

pftdbns 0.2.6


Oliver Bandel announced:
I have to announce version 0.2.6 of pftdbns,
a tool which is useful in sorting/listing/moving files.

It's name "pftdbns" is a short hand for "put files to directories (sorted) by name structure".

It takes filenames, maps each char of the filename into a char, representing
the charclass of it (a..z and A..Z -> "l" (letter), 0...9 -> "i" (integer" and so on)).

This yields to an easy way of sorting files by names, based upon file-naming
with certain filenaming-conventions.

So, for example  "hello.txt" and "ballo.txt" are part of the same name structure,
as well as "1001.txt" and "8251.txt" but also "8251.jpg" are of the same name
structure. For example "foobar.tex" and "foobar.txt" are equally structured too.

The default behaviour is to move files into directories. The names of the directories
are choosen from the string, which represents the name structure by default.


   -inv: inverted template filter: do NOT use the selected files (-tf option)
         but use all other files

   -ad: allow directories to be regarded as valid filenames
        Even if this option is helpful, and new, it also is
        DEPRECATED --> use only, if you know what you are doing ;)

  I also added (since 0.2.5, which also was for correcting errors in the
  documentation) a manpage (as *.man, *.ps, *.pdf) as well as now
  nice readable documentation of the source (created with caml2html).

I hope you enjoy this program, and I think if you have to handle a lot
of files, this will be very helpful.

You can DOWNLOAD the tool here: 

There also is a README in this directory, so that you can read more details.

A DESCRIPTION can also be found here: 

pftdbns can be redistributed under the GPL-license.

AS/Xcaml status


Florian Hars asked and Alex Baretta answered:
> What is the current state of AS/Xcaml? The website still
> points
> to the alpha from april 2004, but people keep hinting to darcs
> repositories and http servers living in other projects' attics on this
> list.
> Is there a version available somewhere that can be built and used by
> mere mortals and is suitable for projects slightly above prototype level?
> Yours, Florian Hars.

The AS/Xcaml is a mature project. We are using it to develop FreerP, a
full fledged ERP application licensed under the GPL. We are also using
it to develop GUI's to PLC applications for industrial machinery.

We have been using darcs for a while to manage the development effort,
but the sheer mass of the project has crushed the pathetic "patch
theory" Roundy declares to have concocted. I am gradually moving
everything over to arch, but I am not having time to breathe, and most
development tasks which are under my responsibility are stalling.

Anyhow, I'll ask my collegues to place a couple of demo applications on
our websites, for the joy of you all. We might also release a snapshot
of the current code, pending the availability of the tla repos.

Ernesto and Dome, do you think we can manage all this today?
Alex Baretta then added:
Try viewing a demo of our glass cutting application at the following URL:

Mozilla or Firefox are required, as the user interface takes advantage
of Mozilla specific features--the sidebar, mainly.
fva asked and Alex Baretta answered:
> I tried having a look at the URL you suggested, out of curio, mainly,
> but the place is locked by password.


Username: starcut
Password: starcut
In another thread, Alex Baretta said:
Since I cannot give you numbers, let me give you ideas about what we
did: we have written a compiler for a functional web oriented
language--the Xcaml--which is to Ocaml what JSP is to Java; we have
written a virtual machine for this language implementing the execution
model for an Xcaml application; since Xcaml needs a very strong level of
intgration with relational DBs, we developed the Xcaml DataBase
Specification language and toolchain, which compiles OO-ER models down
to logical, physical and virtual DB schemas--thus supporting design
refinement at the intermediate level--and compiles the whole thing to
SQL-DDL and to Ocaml database access libraries; the Embedded SQL is a
syntax extension to Ocaml which compiles SQL queries to calls to the
data access libraries generated by the XDBS, thus delegating static
typechecking of SQL queries to the Ocaml type system. Collaterally we
have developed Machiavelli: a event-driven asynchronous servlet
framework, working behind the scenes of the Xcaml application to perform
long running computations that would lock the HTTP user agent for too
long. On top of all this we are developing FreerP--a full fledged ERP
application. We are almost there: FreerP currently manages sales, stock
inventory, logistics, accounting. Besides all this we have developed
Schopenhauer, a realtime soft PLC/CNC based on Ocaml, which we use to
control industrial equipment such as glass cutting machines or metal
sheet cutting machines. Schopenhauer has a seemless integration with the
Xcaml system, so that user interfaces can be based on the web, and can
easily take advantage of the powerful database API. Schopenhauer is
actually our most successful technology commercially, at least this year.

Pattern Matching Papers


Nicolas Cannasse asked:
I'm interested in implementing pattern matching in a ML-like language, and I
need some resources on the following topics :
- pattern matching completeness check
- pattern matching compilation
Papers, tutorials and source code are welcome.
David Mentre suggested:
You should take a look at Luc Maranget papers:
Luc Maranget added:
Thank you for citing my papers!

I'd like to cite some other papers.

* On Backtracking Automata:

- Lennart Augustsson's article includes compiler code.

 <at> inproceedings{5303,
 author = {Lennart Augustsson},
 title = {Compiling pattern matching},
 booktitle = {Proc. of a conference on Functional programming languages and computer architecture},
 year = {1985},
 isbn = {3-387-15975-4},
 pages = {368--381},
 location = {Nancy, France},
 publisher = {Springer-Verlag New York, Inc.},
 address = {New York, NY, USA},

- Phil Wadler's chapter in Simon Peyton Jones book 'Implementation of
  Functional  languages' also provides compiler code.

- Another implementation of the same algorithm is described in Xavier Leroy's
  'Zinc Report'.

* On decision trees (or tree automata)

- M. Pettersson's article, a stimulating approach of this other compilation
  algorithm (LNCS 641).

  <at> inproceedings{727270,
 author = {Mikael Pettersson},
 title = {A Term Pattern-Match Compiler Inspired by Finite Automata Theory},
 booktitle = {CC '92: Proceedings of the 4th International Conference on Compiler Construction},
 year = {1992},
 isbn = {3-540-55984-1},
 pages = {258--270},
 publisher = {Springer-Verlag},
 address = {London, UK},

OMake 0.9.6


Aleksey Nogin announced:
We are proud to announce the latest release of the OMake Build System - 
OMake version 0.9.6.

OMake is a build system, similar to GNU make, but with many additional
features. The home site for OMake is . OMake 
features include:

    o Support for projects spanning several directories or directory

    o Comes with a default configuration file providing support for
      OCaml, C and LaTeX projects, or a mixture thereof.
      Often, a configuration file is as simple as a single line

         OCamlProgram(prog, foo bar baz)

      which states that the program "prog" is built from the files,, and

    o Fast, reliable, automated, scriptable dependency analysis using
      MD5 digests.

    o Portability: omake provides a uniform interface on Win32 and
      on Unix systems including Linux and OSX.

    o Builtin functions that provide the most common features of programs
      like grep, sed, and awk.  These are especially useful on Win32.

    o Full native support for rules that build several files at once.

    o Active filesystem monitoring, where the build automatically
      restarts whenever you modify a source file.  This can be very
      useful during the edit/compile cycle.

    o A companion command interpreter, osh, that can be used

OMake preserves the style of syntax and rule definitions used in
Makefiles, making it easy to port your project to omake.  There is no
need to code in perl (cons), or Python (scons).  However, there are a
few things to keep in mind:

    1. Indentation is significant, but tabs are not required.
    2. The omake language is functional: functions are first-class
       and there are no side-effects apart from I/O.
    3. Scoping is dynamic.

OMake is licensed under a mixture of the GNU GPL license (OMake engine 
itself) and the MIT-like license (default configuration files).

OMake version 0.9.6 features a large number of major improvements and 
bug fixes, including:

   - Added "static" sections that are evaluated once (useful for
     configure-style scripts).
   - Added :value: dependencies, where a target depends on a computed
     value, rather than a file.
   - Changed the meaning of the .SCANNER rules.  .SCANNER rules
     are now much more similar to normal rules.
   - Added file locking for the .omakedb and .omc files.
   - Fixed issues where files were being expanded during the
     string->array conversion.
   - Rule execution now fails when any shell command fails, even those in
     nested sections.
   - Regular expressions now handle \(...\) arguments correctly.  Also,
     the lexer has better performance, searching is now roughly linear
   - Added .SUBDIRS bodies, which can be used instead of the OMakefile
     in a subdirectory.
   - Added the vmount function to define a "virtual mount" of one
     directory over another.
   - Better accessibility of the build rules and dependencies from OMake
   - Improved the latex-related rules.
   - The Map object is completely changed.
   - Other bug fixes and improvements.

For a more verbose change log, please visit .

Source and binary packages of OMake 0.9.6 may be downloaded from . In addition, OMake may be 
obtained via the GODI packaging system (3.08, 3.07 and "dev" branches).

To try it out, run the command "omake --install" in a project directory,
and modify the generated OMakefile.

OMake 0.9.6 is still an alpha release.  While we have made an effort to 
ensure that it is bug-free, it is possible some functions may not behave 
as you would expect.  Please report any comments and/or bugs to the 
mailing list omake <at> and/or at

Idea for another type safe PostgreSQL interface


Richard Jones said:
  [I just throwing this idea out there to see if people find it
  interesting, or want to shoot it down ...  There're only fragments of
  working code at the moment]

I'm thinking about a type safe interface to PostgreSQL.  One such
interface at the moment is in Xcaml, but it only supports a very small
subset of SQL, and I like to use complex SQL.  It seems that there is
a way to support the whole of PostgreSQL's language from within OCaml
programs, in a type safe way.

The general plan would be to have a camlp4 extension which would use
Postgres's new "PREPARE" feature to actually prepare the statements,
and Postgres's other new feature, "Describe Statement", to pull out
the parameter types and result types from the prepared statement.
This allows the camlp4 extension to replace the statement string with
a type safe expression, and allow type inference to find mismatches.
How a typical program would look is shown at the end of this message.

The advantages are:

 * Complete support for PostgreSQL statements with hardly any
   programming effort.
 * Type safe.
 * Schema is stored in one place - the database - and doesn't need
   to be duplicated.

The obvious disadvantages stem from the fact that at _compile time_,
you need to have access to the database.  Perhaps others will think of
other disadvantages.

(I currently don't care about databases which aren't Postgres ...)


Using folding to read the cwn in vim 6+

Here is a quick trick to help you read this CWN if you are viewing it using vim (version 6 or greater).

:set foldmethod=expr
:set foldexpr=getline(v:lnum)=~'^=\\{78}$'?'&lt;1':1

If you know of a better way, please let me know.

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