From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id F18E8BCAE for ; Wed, 6 Jul 2005 11:20:21 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j669KLAL026226 for ; Wed, 6 Jul 2005 11:20:21 +0200 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 LAA23866 for ; Wed, 6 Jul 2005 11:20:20 +0200 (MET DST) Received: from mail.rsise.anu.edu.au (mail.rsise.anu.edu.au [150.203.208.4]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j669KGfq026208 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Wed, 6 Jul 2005 11:20:19 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id 61BFC1DD6F for ; Wed, 6 Jul 2005 19:20:13 +1000 (EST) Received: from mail.rsise.anu.edu.au ([150.203.208.4]) by localhost (mail [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 22276-06 for ; Wed, 6 Jul 2005 19:20:13 +1000 (EST) Received: from pulp.rsise.anu.edu.au (pulp.rsise.anu.edu.au [150.203.208.49]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id 529B11C8B9 for ; Wed, 6 Jul 2005 19:20:12 +1000 (EST) Received: by pulp.rsise.anu.edu.au (Postfix, from userid 1560) id 9EAAD25B789; Wed, 6 Jul 2005 19:20:10 +1000 (EST) Date: Wed, 6 Jul 2005 19:20:10 +1000 From: Pietro Abate To: ocaml ml Subject: class type inside a sig Message-ID: <20050706092010.GA26758@pulp.anu.edu.au> Mail-Followup-To: Pietro Abate , ocaml ml Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: GNU/Linux X-Organization: Research School of Information Science and Engineering (Australian National University) User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mail.rsise.anu.edu.au X-Miltered: at nez-perce with ID 42CBA255.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 42CBA250.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; anu:01 sig:01 sig:01 struct:01 val:01 struct:01 val:01 mismatch:01 anu:01 ...:98 ...:98 arbitrary:01 modules:01 int:01 int:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Hi all, how can I pass a generic class type inside a signature without actually specifying the class itself ? this is a broken example : module type S = sig type t end module Make ( T:S ) = struct let init = new T.t let add s e = s#add e end this is the best I figured out : module type S = sig type c = < add : int -> 'c > as 'c val make : unit -> c end module Make ( T:S ) = struct (* let init = new T.c *) let init = T.make () let add e = init#add e end but it isn't satisfactory as I've to pass a 'make' function and if I try to instantiate the module with a super class of c, it gives me a signature error. For example: class test : c = object val data = [] method add (e :int) = {< data = e::data >} method other = 1 end module A = Make (struct class c = test let make () = new test end) doesn't work because Signature mismatch: Modules do not match: sig class c : test val make : unit -> test end is not included in S Type declarations do not match: type c = < add : int -> c; other : int > is not included in type c = < add : int -> 'a > as 'a the class c in the signature should be a class that has 'at least' a method add with respect to the signature, but it can actually be any arbitrary class... how can I achieve this ? Basically I'd like to say: type c = < add : int -> 'a; .. > as 'a but this doesn't work... :) p -- ++ Blog: http://blog.rsise.anu.edu.au/?q=pietro ++ ++ "All great truths begin as blasphemies." -George Bernard Shaw ++ Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html