Previous week   Up   Next week

Here is the latest Caml Weekly News, week 08 to 15 July, 2003.

1) heap profiling
2) adding data persistency in Ocaml...
3) Seeking feedback on a project
4) new calendar library
5) First alpha release of the FoC library

1) heap profiling
** Fabrice Le Fessant asked and Jean-Christophe Filliatre answered:

>   I would like to know if anybody has implemented some kind of
> memory/heap usage profiling for the current version (3.06) of Ocaml,
> giving for example the amount of live data in the heap allocated by
> each function or module ? or the amount of data retained by some root ?
>   Anybody plans to implement such a tool ?

Regarding  the last  point  (the amount  of  data used  by some  ocaml
values(s)), I implemented a small  module Size for this purpose. It is
available at

2) adding data persistency in Ocaml...
** Basile Starynkevitch said:

I should work (from mid-september 2003) one year at INRIA on adding
data persistency (as much as orthogonal as possible) to
Ocaml. Persistency would use existing support like filesystems or
RDBMS (like MySQL or PostgreSQL etc) or others.

If you have wishes or ideas on how to do it, potential applications in
need of it (CGIs are obvious candidates, but there are other
interested applications) or pitfalls to avoid, or relevant literature,
please feel free to discuss them on the list (or to send it to me if
you feel it is not of general interest).

Obviously the main problem I identified today is to be able to persist
(and share) data with a slight change in the program using it -
persistency for exactly the same program is partly achievable thru the
existing marshalling machinery. I mean that a program persist its
data, then the developer fix a bug and want the modified program to be
able to use the previously persisted data. Perhaps it might require
adding some reflective abilities inside the language, because the
persistence mechanism need to know about the types.

Note that I am not (yet) a persistency or Ocaml internals expert, and
that I am more a coder than a language theorist.

So comments & suggestions are welcome.

3) Seeking feedback on a project
** Matt Gushee said:

I would like to hear your opinions about a project I have been working on
over the last few days.

The project is an OCaml library intended to provide a generic framework
for constructing interactive text-based programs. I see this as being
useful for applications such as configuration editors, expert system
shells, and data entry interfaces.

The way this came about is that I have been wanting such a library for
my own personal use for some time; and lately I have also been curious
about OCaml functors, but didn't quite understand how they worked. So it
occurred to me that it might be appropriate to code this library using
functors, and decided to go ahead and try it.

Now I've developed part of the library, and in so doing have
accomplished one goal: I now have a fairly good understanding of how
functors work. Meanwhile, it turns out that completing this project,  
while not a huge undertaking, will be significantly more work than I
thought at first, so I'm wondering if I should really continue it.

I'd like to ask list members' opinions on the following:

 * Would you find something like this library useful, or do you know
   people who would?
 * Is my approach (see below for more details) a sensible one? Are there
   better ways to attack this problem in OCaml?
 * Does a library of this sort already exist?

To help you answer the above questions, here's a little bit more

The library (tentatively called ShellKit) provides a type of low-level
component called a "shell." The shell is the basic unit of interaction,
and it has the following characteristics:

 - prints some text (usually a prompt, and depending on the type of
   shell, possibly a menu or a brief description), then accepts user
   input on STDIN.
 - has a 'run' function whose signature is:
     run : ?data -> unit -> result
     type result = signal * string option
 - has an associated data type
 - has a function to validate the input
 - can be supplied a default value
 - in addition to handling a specific type of input, can have hooks for
   special global commands such as "help" and "quit."

The basic process for creating a shell looks like:

   configuration -> functor -> shell driver -> functor -> shell

Here's a concrete example:

module BShell = MkShell(
      type t = bool
      let help = None
      let default = None
      let prompt_msg = "Do you like ShellKit?"
      let common = default_shell_options

When you invoke (), it produces a prompt like this:

  Do you like ShellKit? [y/n] >

... then, of course, captures the user's input.

NOTE: If I continue this work, the final product will include structures
for assembling shells into programs, but so far those exist only in
skeleton form.

Anyway, thanks in advance for your comments.

4) new calendar library
** Julien Signoles announced:

I have implemented a new library, called "calendar".
This (small) library contains 5 modules managing dates and times:
        * Time_Zone  (time zones)
        * Period     (periods between two events)
        * Time       (hours, minuts and seconds)
        * Date       (years, months and days)
        * Calendar   (more precise dates using times)

This library is available at:

5) First alpha release of the FoC library
** Damien Doligez announced:

We are pleased to announce the first release of the FOC library,  for
symbolic computation over polynomials. This release also contains a
compiler to Ocaml and Coq source code.

FOC source files contain some declarations and definitions of
functions, some statements about these functions and proofs of these
statements. The main programming features are   
multiple inheritance, late binding, high-level parametrisation and
encapsulation mechanisms.   See the tutorial and the reference manuals
for details (and some research papers on our web site). This release
provides  tools to produce XML formats (Openmath, Omdoc) and some
other tools helping the developer.

The library contains  the  FoC sources for
polynomial arithmetic using various representations:

- a general description of commutative algebra basic structures.
- Implementation of arbitrary precision integers using Ocaml big_ints.
- Polynomials using distributed (sparse) and recursive representations.
- Univariate subresultants calculations.
- Univariate polynomial factorization over finite fields.

Other sources have not been tested enough and are not compiled by
default. They are included for completeness.

This very first version must be considered as an
alpha-version. Although  in principle  proofs are required by the
system, the distributed library contains very few completed
proofs. Developing nice tools to do proofs is our long term goal.
However, the system checks, with the help of the Coq prover,
that using together inheritance, late binding, parametrization do not
lead to inconsistencies. And users can already  do proofs within Coq.

The release is available at:
< >
and < >

The documentation is available on-line:
< >

Should you have any problem with the release, send a mail to Remember that this is work in progress. All
bug reports are welcome and any help will be appreciated.

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 (at least version 6).

:set foldmethod=expr
:set foldexpr=getline(v:lnum)=~'^=\\{78}$'?'<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 ( If you also wish
to receive it every week by mail, just tell me so.


Alan Schmitt