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 KAA24271; Wed, 26 Nov 2003 10:33:30 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA29006 for ; Wed, 26 Nov 2003 10:33:29 +0100 (MET) Received: from paille.cri2000.ens-lyon.fr (paille.cri2000.ens-lyon.fr [140.77.13.113]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hAQ9XT123263 for ; Wed, 26 Nov 2003 10:33:29 +0100 (MET) Received: by paille.cri2000.ens-lyon.fr (Postfix, from userid 44111) id 9E49D34BA2; Wed, 26 Nov 2003 10:42:41 -0800 (PST) From: Tom Hirschowitz MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16324.62497.607234.359869@paille.cri2000.ens-lyon.fr> Date: Wed, 26 Nov 2003 10:42:41 -0800 To: caml-list@inria.fr Subject: [Caml-list] sum types with objects X-Mailer: VM 7.18 under Emacs 21.2.1 Reply-To: Tom.Hirschowitz@ens-lyon.fr X-Loop: caml-list@inria.fr X-Spam: no; 0.00; hirschowitz:01 hirschowitz:01 ens-lyon:01 quantify:01 escapes:01 bool:01 bool:01 explicitely:01 objects:02 objects:02 typing:03 classes:03 classes:03 nil:03 nil:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi all, when trying to implement lists with objects and classes, I run into the following issue. The idea is to define a class type list, parameterized over the type 'a of elements, and containing the methods is_nil, hd, tl, map. Then, I planned to define two classes nil and cons for building objects of type list. The problem arises during the typing of list: # class type ['a] list = object method is_nil : bool method hd : 'a method tl : 'a list method map : ('a -> 'b) -> 'b list end ;; class type ['a] list = object method hd : 'a method is_nil : bool method map : ('a -> 'a) -> 'a list method tl : 'a list end The method map has type ('a -> 'a) -> 'a list, which is not what I want. Trying to explicitely quantify 'b is also wrong, because 'b escapes its scope. Does someone know how to make this work? ------------------- 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