Previous week Up Next week


Here is the latest Caml Weekly News, for the week of 23 to 30 November, 2004.

  1. Objective Caml release 3.08.2
  2. Experiences with learning OCaml?
  3. Config_file : first release
  4. Perl4caml 0.3.14 released
  5. ocaml-xmlr 1.0 released
  6. Functional Reactive Programming in OCaml?

Objective Caml release 3.08.2


Damien Doligez announced:

We have the pleasure of announcing the release of

              Objective Caml version 3.08.2

This is a bug-fix release; see below for the list of changes.
Upgrading is not urgent unless you have problems with one of
the bugs listed below.

Only the source is available at the moment.  We will provide some
binaries in the near future.

It is available at

-- Damien Doligez for the Caml Team

Objective Caml 3.08.2:

Bug fixes:
- runtime: memory leak when unmarshalling big data structures (PR#3247)
- camlp4: incorrect line numbers in errors (PR#3188)
- emacs: xemacs-specific code, wrong call to "sit-for"
- ocamldoc: "Lexing: empty token" (PR#3173)
- unix: problem with close_process_* (PR#3191)
- unix: possible coredumps (PR#3252)
- stdlib: wrong order in Set.fold (PR#3161)
- ocamlcp: array out of bounds in profiled programs (PR#3267)
- yacc: problem with polymorphic variant types for grammar entries 

- export <caml/printexc.h> for caml_format_exception (PR#3080)
- clean up caml_search_exe_in_path (maybe PR#3079)
- camlp4: new function "make_lexer" for new-style locations
- unix: added missing #includes (PR#3088)
Aleksey Nogin added:
Binary and source RPMs for Red Hat Linux 8.0, 9, Fedora Core Release 1, 
2, 3, and Mandrake 10.0 are available at

Experiences with learning OCaml?


Warren asked:
I'm an undergraduate student studying computer science. My course
assignments generally use C, C++, or Java, and I find myself pining for
something more elegant. That is, I'd like to teach myself a functional
programming language of some kind. I don't think I like all the
parentheses in Lisp. But I was very impressed by a Haskell implementation
of the usual quicksort algorithm which was very concise -- only 5 lines or
so. However OCaml seems to have a larger community and has a reputation
for fast executation times, so that seems like a better fit.

The academic term at my university is ending soon and I'll have a few
weeks of free time on my hands -- I was thinking of checking out a
suitable text on some functional programming language from the library and
working through some of it.

Would doing this be difficult if one were sufficiently motivated? I sort
of did something similar with C++ a while ago with some amount of success.

Although I've of course Googled around for potential books to select, are
there any ones particularly suited for someone in my position?

Finally, although OCaml looks interesting, would some other functional
language be better for someone new to functional programming? If so,
which? I ask because I don't know anyone who uses functional languages or
even knows how to use one.
Chen Yang answered:
Firstly, I suggest that you should know some basic theory of lambda
which definitely help you understand functional programming better.
Then you can write some basic algorithms, such as sorting, binary tree, etc.
Here is an good book, , or
you can begin with more simple one,
Richard Jones answered:
I would get yourself a project.  You could contribute to one of the
existing projects here:

or start a new one!

I wrote a tutorial for OCaml users which you may find useful:
Joshua D. Guttman said:
In my opinion, a splendid book that's full of insights into
computation and languages and how to solve problems is Abelson and
Sussman, Structure and Interpretation of Computer Programs (MIT

It uses Scheme, which has the infamous parentheses, but really those
aren't as bad as you think.  In fact, they're a syntactically minimal
way of writing programs, which doesn't get in your way when thinking
about problems.  An outstanding Scheme implementation is PLT Scheme
from Felleisen and his colleagues, now at Northeastern.  

Having taken a tour through Abelson and Sussman, you're sure to feel
at home in OCaml or other functional languages, and probably look at
programming in any language with a clearer pair of eyes.
Michael Vanier added:
I second this (not just because I teach a course based on Structure and
Interpretation of Computer Programs (SICP) ;-)).  Also, you should know
that the book is available for free on its web site: .  I learned most of what I know of functional
programming from reading this book.  Another good book is How to Design
Programs, which also uses scheme, and which also is available for free on
its web site: .  This latter book is extremely
accessible even to non-programmers, although it's somewhat tedious at
first for more experienced programmers.

Ocaml is a fantastic second functional language after you've gotten the
hang of the functional style, and you can learn it straight from the
manuals.  And when you want to go further you should learn Haskell and be
prepared for serious brain-expansion.  

The only problem is that once you've learned languages like scheme, ocaml
and haskell (and I'll throw in common lisp for good measure), you'll find
languages like C, C++, java etc. to be deadly dull and annoying (sort of
like a racing car driver being forced to drive a tricycle).
Danny Yoo added:
I want to third the recommendation.  *grin*  There's also a great set of
video lectures from the SICP authors:
Martin Berger said:
I have to disagree. while SICP is a brilliant book that i used
to teach myself programming from (and nothing i learned as an
undergraduate really went beyond), these days, i'd recommend
Ocaml to beginners. scheme has one VERY BIG problem: it is
untyped (in the sense of static type checking). thinking about
types properly is such an important factor in becoming a good
programmer. it seems to me that there is little one can learn
from scheme that one couldn't learn from ocaml, and probably
learn better.
Michael Vanier said:
I'm not sure how appropriate ocaml is as a beginner's language.  I teach
both scheme and ocaml now, and ocaml is very well-liked by advanced
programmers (one of whom came up to me raving about his "programming
epiphany" after learning ocaml), but I think it would overwhelm beginners.
The syntax is pretty involved, for one thing, and there are just a lot of
concepts to learn.  Cousineau and Mauny's book _The Functional Approach to
Programming_ is a good attempt to teach functional programming and ocaml
(actually caml-light, but it's basically the same) to a fairly naive
William Lovas said:
If you prefer dead trees, a decent book on the functional style is "The
Functional Approach to Programming" by Cousineau and Mauny:

As an added bonus, it uses Caml syntax -- but on the minus side, i really
do mean "Caml" syntax, and not "O'Caml", so there's a small translation
barrier you have to go through.  Nothing that's insurmountable with the
O'Caml manual handy, though.

Config_file : first release


Jean-Baptiste Rouquier announced, and John Goerzen said:
> This lib is used in cameleon and in my own programms. It's available on 
> and on my own webpage.
> It's part of cameleon2 (not yet available) but is also available separately.
> Comments welcome, especially if you know other similar libs. I know Inifiles, 
> Option from cameleon and I couldn't download ConfigParser from Missinglib.

FWIW, you can download it from or (sources are there too).

Perl4caml 0.3.14 released


Richard Jones announced:
I'm pleased to announce the release of perl4caml 0.3.14.  This is a
fully-featured interface for calling Perl code and libraries from
Objective CAML, and includes wrappers around some popular Perl
libraries.  It is released under LGPL + OCaml linking exception.

New in this release are wrappers around the wonderful
WWW::Mechanize[1], and additional coverage of methods in LWP,
HTTP::Request, HTTP::Response, HTTP::Response::Common and

There are also some stability / bug fixes.


I'm still looking for someone with a deep understanding of both
perlguts[3] and OCaml GC, who can help me get the reference counting -
GC interaction working.  At the moment perl4caml does not free any
Perl structures, so is only recommended for short command-line
scripts.  There is experimental code in there to handle Perl's
reference counting, however it sometimes causes crashes and memory
corruption for reasons which are unclear, so it is disabled by



ocaml-xmlr 1.0 released


Evan Martin announced:
I have released version 1.0 of my bindings for libxml's xmlReader API.

The minor changes:
 - Updated Makefile to install libxmlr.a.
 - Minor documentation futzing.
If your existing install works, it is not worth updating.

Otherwise, you can get it from here:
There's a short description of the API here:

Functional Reactive Programming in OCaml?


Benjamin Pierce asked:
I'm sure that, like me, many of you have experienced language-envy when you've 
seen the very cool libraries for Functional Reactive Programming (Fran, Frob, 
Yampa, etc.) that have been implemented in the Haskell world.

Has anybody tried to do something similar in OCaml?  At first sight, it does 
not seem trivial: the implementations of FRP that I've seen make good use of 
many of Haskell's special features -- laziness, type classes and qualified 
types, monads, etc...
James Woodyatt answered:
Hello, Dr. Pierce.  Yes, I've tried this.  Reactive programming is a 
hobby of mine.  I haven't tried building a functional GUI toolkit, 
since I'm mostly interested in network application services.  But you 
might try checking out the Iom module in my OCaml Network Application 
Environment project on SourceForge.

Basically, I ported Chapter 30 of Magnus Carlsson's and Thomas 
Hallgren's joint Ph.D. thesis to OCaml, then generalized it and rewrote 
it to take advantage of OCaml's mutable data structures inside the 

Be advised: the most current release of Cf_gadget has a serious stack 
leak in the scheduler, causing some trivial reactors explode on the 
stack.  A fix-- involving yet another complete rewrite of the 
scheduler-- is already in CVS, and a new release will be coming soon.
Gregoire Hamon answered:
You can look at Lucid Synchrone (,
a functional language dedicated to reactive programming. The syntax is
OCaml's and the compiler produces OCaml code (combining both languages is

While being stream based, reactivity, which is ensured statically, allows
the compiler to produce purely sequential (strict) code.

You can write Fran-like code quite easily (I had some examples which I
can try to find if you're interested).
Benjamin Pierce then asked:
Many thanks to all those who've replied so far to my query about Functional
Reactive Programming in OCaml.  I got some very interesting pointers, but
none closely related to what I was looking for.

I should have been more precise in what I asked -- "FRP" in the Haskell
community is a term with a much more specific technical meaning than just
"reactive programming in a functional style": I was thinking of the line of
work initiated by Conal Eliott and Paul Hudak in their Fran library and
continued in systems like Frob, Fruit, and recently Yampa.  

The common idea in these systems is to introduce an abstraction of "signals"
-- roughly, functions from time to "values", where the values can be
anything from real numbers (conventional signal-processing-type signals) to
two- or three-dimensional pictures, to booleans (representing events).
What's special is that time is represented as a continuous, real-number
quantity.  They do all kinds of work behind the scenes to actually compute
with behaviors, but what shows through in the API is a very simple, elegant,
and powerful set of primitives that can be combined in straightforward ways
to achieve very complex effects.  See for more

So... is anybody doing THAT in OCaml?

Thanks for any (more) pointers.

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