From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 6A4B1BB81 for ; Mon, 13 Feb 2006 21:43:37 +0100 (CET) Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com [66.111.4.28]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k1DKhaL4008834 for ; Mon, 13 Feb 2006 21:43:37 +0100 Received: from frontend1.internal (mysql-sessions.internal [10.202.2.149]) by frontend1.messagingengine.com (Postfix) with ESMTP id A67CDD33DB1; Mon, 13 Feb 2006 15:43:34 -0500 (EST) Received: from frontend2.messagingengine.com ([10.202.2.151]) by frontend1.internal (MEProxy); Mon, 13 Feb 2006 15:43:34 -0500 X-Sasl-enc: KNnQnpidr65KNqiFhuS6J7N41nkGY1m+6NClm/0XoQMu 1139863413 Received: from munge (burnham.ljcrf.edu [192.231.106.2]) by frontend2.messagingengine.com (Postfix) with ESMTP id 8ADF957146E; Mon, 13 Feb 2006 15:43:33 -0500 (EST) Date: Mon, 13 Feb 2006 12:43:07 -0800 (PST) From: Martin Jambon X-X-Sender: martin@munge To: Basile STARYNKEVITCH Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] (quasi FAQ) object, variants, .... Unbound type parameter [..] In-Reply-To: <20060213192936.GA6605@ours.starynkevitch.net> Message-ID: References: <20060213192936.GA6605@ours.starynkevitch.net> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="279748675-379759547-1139863376=:30957" Content-ID: X-Miltered: at concorde with ID 43F0EF78.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 variants:01 basile:01 node:01 node:01 semantics:01 ml-like:01 syntax:01 basile:01 nerim:01 faiencerie:01 92340:01 reine:01 caml-list:01 beginner's:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --279748675-379759547-1139863376=:30957 Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Content-ID: On Mon, 13 Feb 2006, Basile STARYNKEVITCH wrote: > > 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 > end;; > > type > 'a vart = [> `NothingV | `IntegerV of int | `NodeV of 'a nodet ] > and > 'a nodet = Empty | LeafI of int | ObLeaf of 'a instancet | Node of nodet list > and > 'a instancet = ('a,nodet) myclass constraint 'a = 'a vart Maybe something like that: class virtual ['VarT,'NodeT] myclass = object(self) method virtual v : 'VarT method virtual n : 'NodeT end;; (* 'a = 'VarT 'b = 'NodeT *) type ('a, 'b) nodet_poly = Empty | LeafI of int | ObLeaf of ('a, 'b) instancet_poly | Node of ('a, 'b) nodet_poly and ('a, 'b) instancet_poly = ('b, ('a, 'b) nodet_poly) myclass (* 'b = 'NodeT is constrained in vart *) type ('a, 'b) vart = 'b constraint 'b = [> `NothingV | `IntegerV of int | `NodeV of ('a, 'b) nodet_poly ] type ('a, 'b) instancet = (('a, 'b) vart, ('a, 'b) nodet_poly) myclass Martin > I'm getting the following error > > File "ess.ml", 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). > > Regards > > -- > Basile STARYNKEVITCH http://starynkevitch.net/Basile/ > email: basilestarynkevitchnet > aliases: basiletunesorg = bstarynknerimnet > 8, rue de la Faïencerie, 92340 Bourg La Reine, France > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > -- Martin Jambon, PhD http://martin.jambon.free.fr Visit http://wikiomics.org, the Bioinformatics Howto Wiki --279748675-379759547-1139863376=:30957--