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
(quasi FAQ) object, variants, .... Unbound type parameter [..]
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Basile STARYNKEVITCH <basile@s...>
Subject: (quasi FAQ) object, variants, .... Unbound type parameter [..]

Hello All,

I'm a bit ashamed to ask such a quasi FAQ, but I don't understand why
the following does not compile

  class virtual ['VarT,'NodeT] myclass = object(self)
    method virtual v : 'VarT
    method virtual n : 'NodeT

    'a vart = [> `NothingV | `IntegerV of int | `NodeV of 'a nodet ]
    'a nodet = Empty | LeafI of int | ObLeaf of 'a instancet | Node of nodet list
    'a instancet = ('a,nodet) myclass constraint 'a = 'a vart

I'm getting the following error

File "", line 8, characters 12-66:
Unbound type parameter [..]

which is positionned inside the bracket [] of vart line.

Sorry for asking such a nearly FAQ; I thought that this would be a
nearly canical example of the use of constraint.

The real context of all this is some scriptable Wiki-like application
which contains a (dynamically typed) interpreter (quasi scheme
semantics with some ml-like or ada-like syntax). The actual need is to
box in an open variant type (like vart above) all the "special" values
of the interpreter.

Again, my apologies for asking a nearly FAQ... (I googled a bit, but
did not understood the relation between the answers & my question).


email: basile<at>starynkevitch<dot>net 
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France