See also:

OCaml software

This page contains my personal production of software related to the Objective Caml (OCaml) programming language. OCaml is a modern general-purpose and multi-paradigm programming language (functional, imperative, object-oriented) with a strong type system.

I'm the main developer of the CDuce, OCamlDuce and XStream projects, which are developped in OCaml.

I'm also in charge of maintaining some GODI packages. GODI is a package manager / source distribution of OCaml and related sofware. I strongly suggests OCaml users to have a look at it.

Please let me know if you have any suggestion, if you experience any problem, or simply to give some feedback about the software presented in this page.

I'm rarely write useful programs in other languages than OCaml and CDuce. An exception is this extension for Mozilla mail and Thunderbird, which some people find useful.

Sudoku

A small solver for sudoku grids which displays all the solutions. See the Sudoku solver in Objective Caml page.

mtt: experiment in exact type-checking for XML transformations with accumulators

mtt is an exact type-checker for some kind of tree transducers derived from so-called macro-tree transducers. It can be seen as an extended version of xtrans with accumulators.

xtrans: experiment in exact type-checking for XML transformations

xtrans is a simple transformation language for XML documents together with an exact type-checking algorithm. Here, types are seen as sets of XML documents (more precisely, the type algebra can express exactly regular tree languages). Exact type-checking means that the algorithm is sound and complete: if a transformation is well-typed, it will always map values from the specified input type into the specified output type; if a transformation is ill-typed, xtrans will exhibit an input which demonstrates that this property does not hold. This is achieved by taking a transformation language with a limited expressive power (as opposed to Turing-complete programming languages).

The analysis performed by xtrans is inspired by the theory presented in the article Towards Static Type Checking for XSLT by Akihiko Tozawa (Proceedings of the 2001 ACM Symposium on Document engineering, Pages 18-27). The theory has been extended to deal with complex checks (in the paper, only the current tag can be checked) and with support for non-trivial horizontal iteration (this allows, e.g. to perform a different operation on the first element and rest of the sequence, or to write a reverse transformation).

SpiderCaml: binding to SpiderMonkey's Javascript implementation

SpiderMonkey is the historic implementation of Javascript from Netscape, now part of the Mozilla project. More information.

SpiderCaml is a library to use SpiderMonkey from OCaml. In other words, it allows OCaml developpers to embed a Javascript interpreter in their applications.

Bounded-size memoization

This tiny module (together with its interface) implements memoization tables with random access (by computing a hash value for the keys) and bounded size. In case of collisions on the hash value for two keys, the algorithm uses an heuristic to choose which value to keep in the table. It is clever enough to keep the value for a key which has been used strictly more often than all the others keys with the same hash value.

Here is the documentation.

You can do whatever you want with the code.

Thanks to Fabrice Le Fessant for telling me about this nice heuristic.

Recursive: manipulating recursive values with maximal sharing and unique representation

Recursive is a tiny OCaml module that helps the programmer to manipulate cyclic structures (such as recursive types or finite automata) with maximal sharing and unique representation.

ulex: a lexer generator for Unicode

ulex is a lexer generator for Unicode and OCaml.

Please see the download page on CDuce website.

openin: locally open modules

This package implements a Camlp4 syntax extension for Objective Caml. It adds the syntactic construction:

open M in e

that can appear in any context where an expression is expected. M is an arbitrary module expression (not only qualified names as for usual open statements) and e is an expression.

  • Download. Version 2007-05-24 for OCaml 3.10.

Getopt: parsing of command line arguments (à la GNU GetOpt) for OCaml

This module provides a general mechanism for extracting options and arguments from the command line to the program. It is an alternative to the module Arg from the standard OCaml distribution.

The syntax is close to GNU getopt and getopt_long (man 3 getopt).

recode: conversion between characters encodings

A simple front-end to the Netconversion module (in OCamlnet).

XPath

This package implements the XPath recommendation; XPath is a simple query language for XML. A compact XPath expression can perform a relatively complex search on the document tree. XPath is used by XLink and XSLT.

The package is modularized and functorial: the evaluator is a functor taking as argument an implementation of the XPath Data Model as defined in the recommendation.

pa_ocamllex: ocamllex lexers embedded in OCaml programs

pa_ocamllex is a modified version of ocamllex, the lexer generator shipped with Objective Caml. Its implements a Camlp4-syntax extension, and makes it possible to define lexers inside Caml programs.

  • Simplifies Makefile and dependencies generation with ocamldep (no intermediate file).
  • Lexers may now accept extra arguments.
  • Works even with Revised Syntax.
  • Included in next OCaml release.
Note: pa_ocamllex is now included in the standard OCaml distribution.

Postgres: PostgreSQL bindings for OCaml

This libraries allows an OCaml program to query a PostgreSQL database backend.

Note: Markus Mottl has taken over the development of this library to add documentation and tidy up the interface. Since his new release has an incompatible interface, I will continue to maintain my own branch for the many existing happy users. It is quite stable anyway. New users are encouraged to use Markus' version.

HereDoc: syntactic sugar for text producing applications

This module uses Camlp4 to provide syntactic sugar for text producing applications, such as web pages generators, CGI scripts, program generators, ...

  • Download. The version 2006-01-07, with a short documentation (for OCaml 3.08, 3.09). This version corresponds to the current GODI package.

Patches

This section contains patches against the OCaml compiler. They are merely meant as proofs of concept, and they are not maintained.

patch_record: record scoping rule for labels

The patch gives a record scoping rule to labels, when accessing (r.l) or modifying a field in a record (r.l <- e); there must be enough type information to know the type of the record. For instance:

# type t = { x : int } and s = { x : string };;
type t = { x : int; } 
type s = { x : string; } 
# fun r -> r.x;;
- : t -> int = <fun>
# fun (r : t) -> r.x;;
- : t -> int = <fun>
# fun (r : s) -> r.x;;
- : s -> string = <fun>
# fun r -> (r : t).x;;
- : t -> int = <fun>

To apply the patch, download the patch file to the toplevel directory of a fresh OCaml 3.04 source tree, and do:

patch -Np1 < patch_record

Then build OCaml as usual.

Packaged first-class modules for OCaml

This is a patch against OCaml 3.00. It implements first-class modules à la Russo.

See this mail to the Caml mailing list for more information (the syntax for package types is now different). See this file for a classical example using packaged modules (the sieve of prime numbers).

I implemented the unification of signatures as suggested by Xavier Leroy (using check_modtype_equiv).

There is a bug in this release:

# let l=ref [];;
val l : '_a list ref = {contents=[]}
# pack (struct type t = int let f x = l:=[x] end : sig type t val f:t->unit end);;
- : [| sig type t val f : t -> unit end |] =
# l;;
- : t list ref = {contents=[]}

Fixed, but not re-packaged; if you are interested with the patch, let me know.

optional fields in modules

This is a patch against OCaml 3.00. It implements a proposal for a tiny extension of the OCaml module system, allowing optional value fields in module types. This is similar to optional arguments.

See this mail to the Caml mailing list for more information (how to apply the patch, description of the new feature, example).

using primitives from shared libraries

Support for this feature has been integrated to OCaml.

This package consists of a patch to the OCaml 3.00 system. The modified bytecode interpreter (ocamlrun) can load external C functions (aka primitives) from shared libraries, so that it is no longer needed to build a custom runtime system.

I tested the patch under Linux 2.2 and Solaris 5.7.

See the README file for more information.

wlex: a lexer generator for large encodings, derived from ocamllex

Note: I stopped the development of wlex. As it tends to require an update for every single minor OCaml release, it means that wlex will become unusable with the next OCaml release. Instead, I started developping ulex from scratch. It has a better design, and is easier to install and use. Please don't start using wlex now. If your software depends on wlex, please consider switching to ulex. If this is not possible, let me know.
  • Download. Release 2003-09-29 for OCaml 3.07.

Quine

A quine (a.k.a. self-rep) is a program that produces its own source code. Here is an example of a quine written in OCaml.