Jacques Garrigue | 1 Oct 09:25 1996

O'Labl/LablTk/LablBrowser/OCamlBrowser version 1.02

This is mainly a compatibility release, made necessary by O'Caml 1.02.

In O'Labl:
* bug fixes (matching of variants, typing of classes with labels)
* variants may now be recursive

In LablTk:
* compiles with tcl7.4/tk4.0 and tcl7.4/tk4.1
* added grid placement module

In LablBrowser:
* bug fixes, small UI enhancements

	*	*	*

Nouvelles versions de O'Labl/LablTk/LablBrowser/OCamlBrowser
disponibles. Il s'agit principalement d'etre compatible avec O'Caml
1.02, mais de nombreuses erreurs/malfonctions sont corrigees.


Jacques Garrigue	Kyoto University      garrigue <at> kurims.kyoto-u.ac.jp
     <A HREF="http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/">JG</A>
(Continue reading)

Utilisateur FNET | 4 Oct 17:32 1996

Functorized stdlib ???

Attachment: application/octet-stream, 11 KiB
Utilisateur FNET | 4 Oct 17:33 1996

ocamlc syntax and -i option

Attachment: application/octet-stream, 2377 bytes
Jacques GARRIGUE | 7 Oct 10:34 1996

Re: Functorized stdlib ???

>>>>>  <bravier <at> dassault-avion.fr> writes:

 > Here is a suggestion about the standard ocaml library Hashtbl.

 > This module is very useful but it happens to uses the polymorphic
 > equality ( = ) : 'a -> 'a -> bool.

 > Unfortunately, there are cases where you want a hash-table with another
 > equality predicate, for example you might want physical equality ( == ).

 > This is precisely what functors are for !

I have a doubt about the need for modifying specifically Hashtbl for
that.  In fact, there is already a Map module for that. The fact you
have to define a C function (to be efficient) limits the variants you
may have with your functor anyway.

But the general parameterizing problem you expose is interesting.

 > It seems to me that functors and polymorphism might/should go together well.

 > At any rate I would like a way to conceive modules and functors that
 > do not forbid polymorphism because, if you look at the short example :

 > module type ORDER =
 > sig
 >    type 'a t
 >    val ( <= ) : 'a t -> 'a t -> bool
 > end

 > It is really conter-intuitive since I have to parameterize the type t
 > with 'a before any use of type t.

 > What I first wrote (which does not work in the end) was :

 > module type ORDER_first =
 > sig
 >    type t
 >    val ( <= ) : 'a t -> 'a t -> bool
 > end

 > this is what I meant but OrderPoly was not of module type ORDER_first,
 > that's why I finally had to choose type 'a t.

 > Unfortunately this is no real solution since a predicate over
 > couples, say (fun (x1,y1) (x2, y2) -> y1 <= y2) : 'a * 'b -> 'a * 'b -> bool
 > will not fit in module type ORDER whose type 'a t has only one parameter.

 > Well, well, if somebody has clues ...

A (partial solution) would be to use classes, and in my opinion this
is more natural. You generally use only few hashtables/maps of the
same type in the same program, and having to define a module for each
type is a pain. With a class, you can either give the parameter when
creating an object, or define specialized classes by inheritance (as
you would do with a functor). The most interesting point is that you
don't need to prefix your method names by a strange module name: this
is taken from the object.

Here is the interface for map (imperative style : there is an internal
state and modifications return unit, but one could do it functional

class ('a, 'b) map ('a -> 'a -> int) =
  method clear : unit
  method add : 'a -> 'b -> unit
  method find : 'a -> 'b
  method remove : 'a -> unit
  method iter : ('a -> 'b -> unit) -> unit

The parameter is the comparison function which you usually give to the 

Either use it directly

  # let m = new map compare;;
  m : ('_a,'_b) map = <object>

or create a specialized class, integer maps for instance

  # class 'a imap () =
      inherit (int,'a) map (-)

There is still the problem that, at the moment, all polymorphic
variables in methods have to be bound at the class level.
Here this means that we cannot define fold:

  method fold : ('c -> 'a -> 'b -> 'c) -> 'c -> 'c

is not allowed : 'c should be bound at the class level, but then this
is meaningless. You can still simulate it with iter, so this is not
that bad.

Remark also that since functors bind type constructors rather then
types themselves, the map class cannot be defined using the functor,
and the source code has to be modified.

 > By the way, this technique of using paramerized types can also be used
 > to modify the Set module of stdlib to get a polymorphic set type
 > (just change type t into type 'obj t and type elt into type 'obj elt !)

Again I can define a set class, and avoid the problem with multiple
parameters. (I shall distribute this class library soon.)

 > This does not seem much but it enables the user to share code (as I do not
 > know whether applying functors duplicates code or not) and most of all, to
 > use only one module (no need to create modules all over the code ...)

Code is not duplicated, so the reason is mostly making program clearer 
by avoiding the multiplication of modules. We have the same concern.

 > Please, feel free to be controversial :-)

I think I've been :-)

In fact there is here a choice to be done between using
object-oriented features or not. In my opinion object-oriented style
is easier to understand, but modules and functors may be more
"functional". Not only Map and Set, but also Genlex, Hashtbl, Queue,
Stack and Stream can be turned OO with some profit.

In the current version Objective Caml allows both styles, but only
provides support for the first one: there are no predefined classes.
A concern is efficiency, but well implemented there is no reason that
it should be slower than Smalltalk, which is widely used.

On this point, it would be nice to have a clearer view of what
Objective Caml is going to be, if somebody knows.

	Jacques Garrigue

Christine Paulin | 6 Oct 17:38 1996

ocaml-tex ?


Je ne trouve pas dans la distribution trace d'un outil analogue a 
caml-tex compatible avec ocaml. Une modification naive du scrip caml-tex
ne semble pas suffisante.
Quelqu'un s'est-il penche sur ce probleme ?
Merci d'avance.
Christine Paulin.


New Introductory book (in German) using Caml light

Algorithmen -- Datenstrukturen -- Funktionale Programmierung -
 Eine praktische     Einf|hrung mit Caml-Light,
 Juergen Wolff v. Gudenberg,
 Addison-Wesley, Bonn 1996 

About the book:

The design of algorithms, their implementation and the handling of
 data structures belong to the basic tools of each computer scientist.

This book gives an introduction where algorithms as well as data structures
 are considered functionally. It is intended as an accompanying book
 for basic courses in computer science,
 but it is also suitable for self-studies.

In the first part the algorithms are concisely and precisely  designed
 using  Caml Light as a kind of pseudo code. The main ideas are thus not
concealed by a lot of details.
As an additional advantage the pseudo code describes complete programs
 and the designs are directly executable.
In this manner the reader becomes familar with functional programming.

The second part provides a tutorial introduction into the language Caml Light
and in its last chapter a comprehensive description of the language kernel.

Caml Light is an easily portable, typed, functional language
 which is interpreted but may also be compiled if neccessary.
There is a considerable amount of interesting application modules.

The sample programs for all algorithms mentioned in the book are freely 
available as well as the system itself.



___________________()/ ()______________________________________________________

 Prof. Dr. J. Wolff v. Gudenberg 		Lehrstuhl fuer Informatik II
 wolff <at> informatik.uni-wuerzburg.de		Universitaet Wuerzburg
 Tel. 0931 / 888-5517				Am Hubland	
 Fax. 0931 / 888-4602				D-97074 Wuerzburg
 URL  http://www-info2.informatik.uni-wuerzburg.de/staff/wvg

Jean-Christophe Filliatre | 9 Oct 09:12 1996

camllight graphics and video card S3 trio 64V+, etc.


[ I post this questions for 3 persons who do not have access to mail ]

1. I have a video card "S3 trio 64 V+ PCI" and there seems to be no
driver for this
card in order to use the graphics library of camllight 0.71 under DOS.
Is it possible to get it somewhere ? Or is there any "standard" SVGA
driver which can be used with this card ?

2. Is the 256 colors limitation of the graphics library inherent to this
or is it possible to find drivers for more than 256 colors (for 24 bits
video cards
for instance) ?

Thank you.



| Jean-Christophe FILLIATRE
(Jean-Christophe.Filliatre <at> ens-lyon.fr)       |
|   WWW:
http://www.eleves.ens.fr:8080/home/filliatr/                     |

Xavier Leroy | 9 Oct 10:49 1996

Re: ocaml-tex ?

[Christine Paulin was asking for a version of the caml-tex formatter
 that works with Objective Caml. One is at the end of this message.]

> Je ne trouve pas dans la distribution trace d'un outil analogue a 
> caml-tex compatible avec ocaml. Une modification naive du scrip caml-tex
> ne semble pas suffisante.

Nous avons une version modifiee de caml-tex pour Objective Caml qui
sert a fabriquer la documentation. Elle n'est pas dans la distribution
pour diverses raisons, en particulier parce que le perl script n'est
pas tres propre et qu'il faudrait trouver mieux. Je l'inclus a la fin
de ce message. Attention, ca marche avec Objective Caml 1.02 mais pas
1.01 (changement des prompts du system interactif).

- Xavier Leroy


$camllight = "TERM=dumb ocaml";
$camlbegin = "\\caml\n";
$camlend = "\\endcaml\n";
$camlin = "\\?";
$camlout = "\\:";
$camlblank = "\\;\n";

$linelen = 72;
$output = "";
$cut_at_blanks = 0;

while ($#ARGV >= 0) {
  $_ = $ARGV[0];
  last unless (/^-/);
  $linelen = $ARGV[1], shift, shift, next    if (/^-n$/);
  $output  = $ARGV[1], shift, shift, next    if (/^-o$/);
  $camllight = $ARGV[1], shift, shift, next    if (/^-caml$/);
  $cut_at_blanks = 1, shift, next            if (/^-w$/);
  printf STDERR ("Unknown option '%s', ignored\n", $_);

# First pass: extract the Caml phrases to evaluate

open(ML, "> .input.ml") || die("Cannot create .input.ml : $!");

foreach $infile ( <at> ARGV) {
  open(IN, $infile) || die("Cannot open $infile : $!");
  while(<IN>) {
    if (m/^\\begin{caml_(example|example\*|eval)}\s*$/) {
      while(<IN>) {
        last if m/^\\end{caml_(example|example\*|eval)}\s*$/;
        print ML $_;


# Feed the phrases to a Caml toplevel

open(TOPLEVEL, "$camllight 2>&1 < .input.ml |") ||
       die("Cannot start camllight : $!");

<TOPLEVEL>; <TOPLEVEL>;		# skip the banner
$lastread = <TOPLEVEL>;
$lastread =~ s/^# //;

# Second pass: shuffle the TeX source and the output of the toplevel

if ($output) {
  if ($output eq "-") {
    open(OUT, ">&STDOUT");
  } else {
    open(OUT, ">$output") || die("Cannot create $output: $!");

foreach $infile ( <at> ARGV) {
  open(IN, $infile) || die("Cannot open $infile: $!");
  if (! $output) {
    $outfile = $infile;
    $outfile =~ s/\.tex$//;
    open(OUT, "> $outfile.ml.tex") || die("Cannot create $outfile.ml.tex: $!");
  while(<IN>) {
    if (m/^\\begin{caml_example(\*?)}\s*$/) {
      $omit_answer = $1;     # true if caml_example*, false if caml_example
      print OUT $camlbegin;
      $severalphrases = 0;
      while(<IN>) {
        last if m/\\end{caml_example\*?}\s*$/;
        print OUT $camlblank if ($severalphrases);
        while(1) {
          print OUT $camlin, $_;
          last if m/;; *$/;
          $_ = <IN>;
	while ($lastread =~ s/^  //) { }
        while($lastread) {
          last if $lastread =~ s/^# //;
          print STDERR $lastread;
          if (! $omit_answer) {
            while (length($lastread) > $linelen) {
              if ($cut_at_blanks) {
                $cutpos = rindex($lastread, ' ', $linelen);
                if ($cutpos == -1) { $cutpos = $linelen; } else { $cutpos++; }
              } else {
                $cutpos = $linelen;
              $line = substr($lastread, 0, $cutpos);
              $line =~ s/\\/\\\\/g;
              print OUT $camlout, $line, "\n";
              $lastread = substr($lastread, $cutpos,
                                 length($lastread) - $cutpos);
            $lastread =~ s/\\/\\\\/g;
            print OUT $camlout, $lastread;
          $lastread = <TOPLEVEL>;
        $severalphrases = 1;
      print OUT $camlend;
    elsif (m/^\\begin{caml_eval}\s*$/) {
      while(<IN>) {
        last if m/^\\end{caml_eval}\s*$/;
        if (m/;; *$/) {
	  while ($lastread =~ s/^#//) { }
	  while($lastread) {
	    last if $lastread =~ s/^#//;
	    print $lastread;
	    $lastread = <TOPLEVEL>;
    else {
      print OUT $_;


Vyskocil Vladimir | 9 Oct 11:25 1996

Constructeurs en O'Caml


Existe-t'il comme en C++ une fonction qui est appelee a la construction d'un 
objet (pas seulement pour initialiser des variables d'instances) ?

Vyskocil Vladimir
vvyskoci <at> sophia.inria.fr

Xavier Leroy | 9 Oct 11:44 1996

Re: camllight graphics and video card S3 trio 64V+, etc.

> 1. I have a video card "S3 trio 64 V+ PCI" and there seems to be no
> driver for this
> card in order to use the graphics library of camllight 0.71 under DOS.
> Is it possible to get it somewhere ? Or is there any "standard" SVGA
> driver which can be used with this card ?

You're probably talking about release 0.7 or earlier. You should try
VESA_S3.GRN first, which seems to be a "generic" S3 driver. If this
fails, try other drivers for cards that have S3 chips in them, such as

This said, graphics under MSDOS are a mess, and you're strongly
encouraged to do graphics under the Windows version of Caml Light 0.71.
At least, Windows takes care of the graphics drivers.

> 2. Is the 256 colors limitation of the graphics library inherent to
> this library, or is it possible to find drivers for more than 256
> colors (for 24 bits video cards for instance) ?

The graphics code for 0.7 was built on top of the CBGRX library for
DJGPP version 1, and I don't think this library can handle more than
256 colors. (This is code I wrote almost five years ago, so I can be

For 0.71, Caml Light will happily let you access all colors that
Windows provides.

- Xavier Leroy