Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: -- (:)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] lablgtk polymorphic variants question
From: Ruchira Datta <>

> 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:
> The declaration of MathView.get_frame is on lines 85-86 of, 
> in module MathView:
>   external get_frame : [>`math_view] obj -> [`frame] obj =
>    "ml_gtk_math_view_get_frame"

This is wrong. This should be:
  external get_frame : [>`math_view] obj -> Gtk.frame obj =

> The declaration of Gtk.frame is on line 95 of
> 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.

LablGTK uses an encoding of widget types, in variant types, were
variant types are used as capacities. This can seem a bit unusual, but
you can see it in the fact the Gtk.obj abstract type is contravariant.

    Jacques Garrigue
To unsubscribe, mail  Archives: