caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Functors and classes
@ 2004-08-03 12:02 Richard Jones
  2004-08-03 12:10 ` Richard Jones
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Jones @ 2004-08-03 12:02 UTC (permalink / raw)
  To: caml-list


I'm trying to replace the current mod_caml approach to pooling
database handles with a functorized one.  However there seems to be
some problem with the way functors and classes interact.

I have a hierarchy of classes:

      Dbi.connection
           |
           ^
           |
   +----------- - - - etc.
   |
 Dbi_postgres.connection

I'd like to create a pool of "postgres connections" using something
like:

  module MyPool = Apache.DbiPool (Dbi_postgres)

So far, the apache.mli looks like below.  It doesn't compile because:

  Unbound type constructor DbiConnection.connection

at the last line.

Is this sort of thing even possible?

Rich.

------------------------------------------------------- apache.mli ---------
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 = DbiConnection.connection
----------------------------------------------------------------------

-- 
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
MAKE+ is a sane replacement for GNU autoconf/automake. One script compiles,
RPMs, pkgs etc. Linux, BSD, Solaris. http://www.annexia.org/freeware/makeplus/

-------------------
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


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-08-03 23:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-03 12:02 [Caml-list] Functors and classes Richard Jones
2004-08-03 12:10 ` Richard Jones
2004-08-03 13:17   ` Richard Jones
2004-08-03 15:06     ` John Prevost
2004-08-03 15:12       ` Richard Jones
2004-08-03 15:27         ` John Prevost
2004-08-03 15:28           ` John Prevost
2004-08-03 19:57             ` brogoff
2004-08-03 22:05               ` brogoff
2004-08-03 23:24                 ` John Prevost
2004-08-03 15:50       ` Richard Jones
2004-08-03 16:23         ` John Prevost
2004-08-03 16:42           ` Richard Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).