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 (15:06)
From: John Prevost <j.prevost@g...>
Subject: Re: [Caml-list] Functors and classes
The following model works for me.  The key problem here is that
there's no way to bring a class binding in in the way you want. 
That's not really a problem, except that you lose the ability to call
"new".  Perhaps the Dbi interface could be changed to allow for this? 
(Depending on how you do things, this could mean that a DbiPool could
itself be used as a Dbi module, somehow.)

It's also possible that I'm missing some way to otherwise do this.


module TestThing =
    class connection =
        method a = 1
	method b = 1
	method c = 1
    let connect () = new connection

module type ThingIntf = 
    type connection
    val connect : unit -> connection

module type ThingPoolT =
    type connection
    val connect : unit -> connection

module ThingPool (Thing : ThingIntf) :
    (ThingPoolT with type connection = Thing.connection) =
    type connection = Thing.connection
    let connect () = Thing.connect ()

module X = ThingPool(TestThing)

let x = X.connect ()

let a = x #a
let b = x #b
let c = x #c

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