[...
:
module type SOURCE = sig
type 'a ctx = 'a constraint 'a = #CouchDB.ctx
type source
val get : source -> 'a ctx -> string
end
, , :
module type SOURCE = sig
type source
val get : source ->
end
: , OCaml . , , , . get CouchDB.ctx - , ( ), .
val get : source -> CouchDB.ctx -> string
, . CouchDB.ctx - , , . . : .
======]
2: , . , OCaml. . ,
module type SOURCE = sig
type ctx < CouchDB.ctx
...
end
OCaml. , , :
module type SOURCE = sig
type ctx
val up : ctx -> CouchDB.ctx
type source = string
val get : source -> ctx -> string monad
end
Cache ctx#get (S.up ctx)#get, ctx#put.
module Cache = functor (S:SOURCE) -> struct
type ctx = S.ctx
type source = S.source
let get source ctx =
bind ((S.up ctx)
end
module SomeSource = struct
type ctx = AsyncDB.ctx
let up ctx = (ctx : ctx :> CouchDB.ctx)
type source = string
let get s ctx = ...
end
module SomeCache = Cache (SomeSource)
, type source = string SOURCE. , ctx#get source Cache.