Previous week Up Next week


Here is the latest Caml Weekly News, for the week of 22 to 29 November, 2005.

  1. Mandelbrot renderer
  2. polymorphic fixpoints operator in Ocaml
  3. Interface to Boom SMS (text message service)
  4. HDCaml 0.2.5 -- SystemC Support
  5. Physical compare
  6. Library for reading and writing CSV (comma-separated values) files
  7. findlib-1.1.1 released
  8. ile ou un remplacement?

Mandelbrot renderer


Jon Harrop announced:
Following Oliver's objections regarding the lack of serious software written 
in OCaml (e.g. web servers), I have written a very serious Mandelbrot 
renderer. The program is 35 lines of OCaml and renders using OpenGL. This 
page breaks it down and describes how it works:

I've written a simple, recursive C++ version as well. It weighs in at 45 lines 
but only 6% more bytes. If you specialise the complex-number arithmetic in 
the OCaml:

  let rec mandelbrot i cx cy zx zy =
    if i = 63 || zx *. zx +. zy *. zy > 4. then i else
      let zx = zx *. zx -. zy *. zy and zy = 2. *. zx *. zy in
      mandelbrot (i+1) cx cy (zx +. cx) (zy +. cy)

then, with only -O3, the C++ is actually significantly slower. The performance 
of the C++ improves considerably with -ffast-math so that it is slightly 
faster. The performance of the C++ can be further improved by using an 
imperative style. This is on both AMD64 and x86.

polymorphic fixpoints operator in Ocaml


Jacques Carette announced:
Inspired by Julien Signoles' code for Omega, ( Oleg K explores different ways to create a *fully polymorphic* fixpoint operator in Ocaml.  See 

for details.

Interface to Boom SMS (text message service)


Richard Jones announced:
Not likely to be of wide interest, but we have implemented a simple
interface to the commercial Boom SMS (text message sending) service.
We use this to generate alerts when significant things happen while
automatically bidding on Google Adwords.

License is LGPL + OCaml linking exception.


Read more about the commercial service here.  If you want to test it,
they will give you up to 50 free text messages (if you ask them).

HDCaml 0.2.5 -- SystemC Support


Tom Hawkins announced:
HDCaml is a hardware design and verification language embedded in OCaml.

With release 0.2.5, HDCaml now produces cycle and bit accurate C models 
for simulation.  In addition to the logic primitives, the C models also 
support basic assertions of the form:

   assertion "label" (always (prop (some_signal)));

The C models include a SystemC wrapper for integration into any SystemC 
environment.  The wrapper is currently untested, so feedback from any 
SystemC user is appreciated.  Thanks!

Physical compare


Tom Hawkins asked and Nicolas Cannasse answered:
> Is their a version of "compare" that is based on physical equality?  If 
> not, how can I define one?  I tried:
> let compareq a b = if a == b then 0 else if a > b then 1 else (-1)
> But unfortunately, (>) is a structural comparison.
> I need to make a Map where the keys are distinguished by the physical 
> instance.

It's not possible.

One of the reason is that the GC might move your memory addresses around 
and then break your Map constitency. You need to attribute an unique id 
to each of your items and use it for comparison.
Jon Harrop suggested:
Tag every key with a unique integer using something like this:

module Tag : sig
  type 'a t
  val make : 'a -> 'a t
  val compare : 'a t -> 'a t -> int
end = struct
  type 'a t = int * 'a
  let i = ref 0
  let make x =
    incr i;
    !i, x
  let compare (a, _) (b, _) = compare a b

Then use the function to perform physical comparison with a total 
Jean-Christophe Filliatre also suggested:
Others already  gave the right answer  i.e. that you need  to tag your
values with unique integers to do that.

Just to  mention it, I wrote  a little hash-consing  library that does
precisely this, together with specialized  versions of Set and Map for
these tagged values  (based on Patricia trees). There  is even a short
article describing the technique. All is available on this page:

Library for reading and writing CSV (comma-separated values) files


Richard Jones announced:
Version 1.1.0 has been released.


findlib-1.1.1 released


Gerd Stolpmann announced:
there is a new version of findlib (1.1.1) with two minor bug fixes,
especially for O'Caml 3.09.

for documentation and links. See
for downloads.

ile ou un remplacement?


Christopher Alexander Stein asked:
J'avais l'habitude d'avoir une utilité très commode pour Caml; la ligne éditant 
"ile" qui envelopperait l'interprèteur. Je puis plus ne le trouver sur le web.  
N'importe qui savent où il est ou suggèrent un remplacement?

(Editor's translation: the poster is looking for the line editor "ile" or a 
remplacement that would allow him, when using it with the toplevel, to have a 
better line editing experience.)
Eric Cooper suggested:
Try ledit, available as a Debian package or from
Michael Wohlwend suggested:
there is also rlwrap which is easier to use. (readline wrap)
Martin Jambon suggested:
There is some useful information there, and you are welcome to contribute 
Alain Frisch said:
Google donne ce lien:

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}$'?'<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