English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] lablgtk polymorphic variants question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-03-19 (06:13)
From: Ruchira Datta <datta@m...>
Subject: [Caml-list] lablgtk polymorphic variants question
I tried to compile lablgtkmathview but ran into an error.  I would guess
that it probably compiled under OCaml 3.00 but doesn't for me since I have
3.01.  I have lablgtk 1.2.0.  (Everything is from Sven Luther's Debian
packages, except lablgtkmathview and mlminidom which don't seem to be
packaged yet.)  The error:

File "gMathView.ml", line 61, characters 36-58:
This expression has type [ `frame] Gtk.obj but is here used with type
  Gtk.frame Gtk.obj
Type [ `frame] is not compatible with type
  Gtk.frame = [ `widget | `container | `bin | `frame] 

The offending line is:

 method get_frame = new GBin.frame (MathView.get_frame obj)

The declaration of MathView.get_frame is on lines 85-86 of gtkMathView.ml, 
in module MathView:

  external get_frame : [>`math_view] obj -> [`frame] obj =
The declaration of Gtk.frame is on line 95 of gtk.ml:

type frame = [`widget|`container|`bin|`frame]

I guess I don't fully understand polymorphic variants.  It would have seemed
to me that if (new GBin.frame) expects an argument of type Gtk.frame, then
something of type [ 'frame] should satisfy it.  Why should it be necessary
that all four variants [`widget|`container|`bin|`frame] be able to occur?
I thought that the inferred type of a function would always allow less 
variants in its argument.

Ruchira Datta
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr