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 VAA08109; Tue, 3 Aug 2004 21:57:47 +0200 (MET DST) 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 VAA07589 for ; Tue, 3 Aug 2004 21:57:46 +0200 (MET DST) Received: from mail5.speakeasy.net (mail5.speakeasy.net [216.254.0.205]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i73JviRM014120 for ; Tue, 3 Aug 2004 21:57:44 +0200 Received: (qmail 5537 invoked from network); 3 Aug 2004 19:57:41 -0000 Received: from shell2.speakeasy.net ([69.17.110.71]) (envelope-sender ) by mail5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 3 Aug 2004 19:57:41 -0000 Date: Tue, 3 Aug 2004 12:57:40 -0700 (PDT) From: brogoff To: Ocaml Mailing List Subject: Re: [Caml-list] Functors and classes In-Reply-To: Message-ID: References: <20040803120244.GA22304@annexia.org> <20040803121049.GA22418@annexia.org> <20040803131716.GA22773@annexia.org> <20040803151241.GA25124@annexia.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 410FEE38.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; brogoff:01 brogoff:01 caml-list:01 functors:01 prevost:01 val:01 val:01 struct:01 demonstrate:01 stab:01 caveat:01 struct:01 conn:01 conn:01 blah:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, 3 Aug 2004, John Prevost wrote: > Oops. A couple of errors in that last thing I wrote that weren't the > problem I was trying to illustrate (that's what I get for trying fixes > inline before giving up): > > module type ThingPoolT = > sig > type connection > val connect : unit -> connection > val test : connection -> int > end > > module ThingPool (Thing : ThingIntf) : > (ThingPoolT with type connection = Thing.connection) = > struct > type connection = Thing.connection > let connect () = Thing.connect () > let test x = x#a + 1 > end Certainly if you're going to call method a it needs to be exposed. If I understand the problems you're trying to demonstrate, the following would be my stab at it. Untested code, caveat emptor, blah blah blah... module type ThingIntf = sig type 'a connection = 'a constraint 'a = < a: int; connect : unit -> 'a connection; ..> val connect : unit -> 'a connection end;; module type ThingPoolT = sig include ThingIntf val test : 'a connection -> int end;; module ThingPool (Thing : ThingIntf) : ThingPoolT = struct include Thing let connect () = let conn = Thing.connect () in ignore (conn#a); conn let (test : _ connection -> int) = fun x -> x#a + 1 end;; -- 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