From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA26497; Mon, 8 Jul 2002 03:25:16 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA20547 for ; Mon, 8 Jul 2002 03:25:15 +0200 (MET DST) Received: from night.its.uiowa.edu (night.its.uiowa.edu [128.255.56.106]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g681PE903032 for ; Mon, 8 Jul 2002 03:25:14 +0200 (MET DST) Received: from uiowa.edu (host38-92.uihc.uiowa.edu [129.255.38.92]) by night.its.uiowa.edu (8.11.6/8.11.6/ns-mx-1.14) with ESMTP id g681PCl208208 for ; Sun, 7 Jul 2002 20:25:12 -0500 Message-ID: <3D28E9F8.5020308@uiowa.edu> Date: Sun, 07 Jul 2002 20:25:12 -0500 From: Brian Smith User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1a) Gecko/20020611 X-Accept-Language: en-us, en MIME-Version: 1.0 To: OCaml Mailing list Subject: [Caml-list] Polymorphic methods (longest error message ever!) Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi everybody, First of all, where can I find some documentation about the CVS versino of O'Caml? Is the documentation kept in CVS too? Anyway, on to the problem at hand: I have a class like this: class type ['a] node_type = object method as_variant : 'a constraint 'a = [> `Node of 'a node_type] end;; class ['a] node : ['a] node_type = object (self) method as_variant : 'a = `Node (self :> 'a node_type) end;; That works fine in O'Caml 3.04. But, I want to use the new polymorphic method feature in O'Caml 3.04+15. So I tried: # class type node_type = object method as_variant : [> `Node of node_type] end;; class type node_type = object method as_variant : [> `Node of node_type] end # class node : node_type = object (self) method as_variant = `Node (self :> node_type) end;; ^^^^ This expression cannot be coerced to type node_type = < as_variant : 'a. [> `Node of node_type] as 'a >; it has type < as_variant : 'c; .. > as 'b but is here used with type 'b # class node : node_type = object (self) method as_variant : 'a. [> `Node of node_type] as 'a = `Node (self :> node_type) end;; The class type object method as_variant : [> `Node of node_type] end is not matched by the class type node_type The class type object method as_variant : [> `Node of node_type] end is not matched by the class type object method as_variant : [> `Node of node_type] end The method as_variant has type 'a. [> `Node of node_type] as 'a but is expected to have type 'b. [> `Node of node_type] as 'b The universal variable 'b would escape its scope I have no idea what the error message means. To me, it is saying that class "node" doesn't match class type "node_type" even though everything has exactly the same type. Could somebody please explain it to me? What is the correct way of doing the above? Thanks, Brian ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners