From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p2JK2cw4027304 for ; Sat, 19 Mar 2011 21:02:38 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArAHACaohE0+3JIE/2dsb2JhbACYSzGMeXeITbkmhWMEjGeDUQ X-IronPort-AV: E=Sophos;i="4.63,211,1299452400"; d="scan'208";a="94462601" Received: from vs.philou.ch ([62.220.146.4]) by mail2-smtp-roc.national.inria.fr with ESMTP; 19 Mar 2011 21:02:33 +0100 Received: from [192.168.1.120] (85-218-16-131.dclient.lsne.ch [85.218.16.131]) by vs.philou.ch (Postfix) with ESMTPSA id 981BF232347; Sat, 19 Mar 2011 21:02:32 +0100 (CET) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=iso-8859-1 From: Philippe Strauss In-Reply-To: <201103191648.40345.raphlalou@gmail.com> Date: Sat, 19 Mar 2011 21:02:28 +0100 Cc: Raphael Proust Message-Id: References: <201103191648.40345.raphlalou@gmail.com> To: caml-list@yquem.inria.fr X-Mailer: Apple Mail (2.1082) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p2JK2cw4027304 Subject: Re: [Caml-list] Recursive Parametric class type Typing Jacques answered me about a parametrized class prob. I had some time ago, about an important restriction: "Object types are allowed to be recursive, but they are restricted to _regular_ types, where recursive occurences have identical type parameters. In particular, this means that in the above line, ('a,'b) node_virt_t and ('b,'c) node_virt_t must have the same parameters, i.e. that 'a = 'b and 'b = 'c, i.e. all your types end up being identical." (maybe an FAQ is somewhat missing on the main, inria, ocaml website about that kind of infos.?) Le 19 mars 2011 à 16:48, Raphael Proust a écrit : > Hi list, > > Trying to bind a javascript library for js_of_ocaml, I encountered the following > pattern (here drastically simplified): > > class type ['t] c = > object > method plus: 't -> unit > method minus: unit -> 't > method container: unit -> container > end > and container = > object > method int: unit -> int c > method string: unit -> string c > end > > The following error is raised at compile time: > Error: This type string should be an instance of type int > > In the use case: > - instead of [int] and [string] there are six different [class type]s; > - [classe type]s have more methods; and > - there are additional recursive [class type]s > > > Why is there such a limitation on the types? Is there a work around that > wouldn't induce (too much) code duplication? > > Thanks, > -- > ______________ > Raphaël Proust > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >