Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Functors and classes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-08-03 (13:17)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Functors and classes
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 ->
    method close : unit -> unit
    method closed : bool
    method ping : unit -> bool
    method rollback : unit -> unit


module type DbiPoolT = sig

  type connection

  val get : Request.t -> ?host:string -> ?port:string ->
    ?user:string -> ?password:string -> string -> connection

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/", 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

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

I tried to define an "open class" (<method; method; ..>) 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; .. >


but this gives a syntax error.

Ideas on how to solve this one?


Richard Jones.
Merjis Ltd. - improving website return on investment
NET::FTPSERVER is a full-featured, secure, configurable, database-backed
FTP server written in Perl:

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: