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 PAA22763; Tue, 3 Aug 2004 15:17:19 +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 PAA22744 for ; Tue, 3 Aug 2004 15:17:18 +0200 (MET DST) Received: from annexia.force9.co.uk (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i73DHHSH029023 for ; Tue, 3 Aug 2004 15:17:17 +0200 Received: from rich by annexia.force9.co.uk with local (Exim 3.36 #1 (Debian)) id 1BrzAK-00067e-00 for ; Tue, 03 Aug 2004 14:17:16 +0100 Date: Tue, 3 Aug 2004 14:17:16 +0100 To: caml-list@inria.fr Subject: Re: [Caml-list] Functors and classes Message-ID: <20040803131716.GA22773@annexia.org> References: <20040803120244.GA22304@annexia.org> <20040803121049.GA22418@annexia.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040803121049.GA22418@annexia.org> User-Agent: Mutt/1.5.5.1+cvs20040105i From: Richard Jones X-Miltered: at concorde with ID 410F905D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 functors:01 mli:01 val:01 dbi:99 dbi:99 compiles:01 instantiate:01 postgres:01 mismatch:01 postgres:01 ltd:98 bool:01 bool:01 caml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk OK, I have another problem. My apache.mli now looks like this: ---------------------------------------------------------------------- module type DbiConnection = sig class connection : ?host:string -> ?port:string -> ?user:string -> ?password:string -> string -> object method close : unit -> unit method closed : bool method ping : unit -> bool method rollback : unit -> unit end end module type DbiPoolT = sig type connection val get : Request.t -> ?host:string -> ?port:string -> ?user:string -> ?password:string -> string -> connection end module DbiPool (Dbi : DbiConnection) : DbiPoolT with type connection = Dbi.connection ---------------------------------------------------------------------- This compiles fine, with the corresponding .ml file. However when I try to instantiate a pool using: module Pool = DbiPool (Dbi_postgres) I get errors: File "examples/useful-scripts/maillist.ml", line 49, characters 23-35: Signature mismatch: Modules do not match: [...] The public method commit cannot be hidden The public method database cannot be hidden The public method database_type cannot be hidden [etc.] I understand why this happens, because the actual Dbi_postgres.- connection class is much more complicated than the mere four methods which I need to use to make the pool work. However, importing the entire class type is complex in three respects: it depends on a bunch of other classes which need to be imported; and it means that a particular version of mod_caml becomes very dependent on a particular version of ocamldbi; and (crucially, fatally) the different database subclasses may all contain extra and different public methods, so there is no way to list all the public methods anyway. I tried to define an "open class" () using: module type DbiConnection = sig class connection : ?host:string -> ?port:string -> ?user:string -> ?password:string -> string -> < close : unit -> unit; closed : bool; ping : unit -> bool; rollback : unit -> unit; .. > end but this gives a syntax error. Ideas on how to solve this one? Rich. -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment NET::FTPSERVER is a full-featured, secure, configurable, database-backed FTP server written in Perl: http://www.annexia.org/freeware/netftpserver/ ------------------- 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