Hello, While using the module system to abstract types, I often encounter the problem to reuse in a signature an abstract type declared in another signature. Let's take an example. I have a module M, which declares an abstract type t, with operations using this type.
module type MT = sig type t val f : t -> .... end Now I want to design a module Q, with operations using type t. To refer to t in the signature of Q, I am obliged to declare a module Mt : MT inside the signature module type QT = sig module Mt : MT val g : Mt.t -> .... end Now the module M itself, before Q, because of sharing constraint in Q: module M : MT = struct type t = int let f x = .... end And finally the module Q, which must contain a module Mt to respect its signature: module Q : (QT with type Mt.t = M.t) = struct module Mt = M let g x = .... end As generally my modules are functors I will probably rather write the module QF: module QF (Mx:MT) : (QT with type Mt.t = Mx.t) = struct module Mt = Mx let g x = ... end And finally instanciate QF: module Q2 = QF (M) The declaration of Mt in QT and QF is here only to reference the type t. It seems natural that QF be parameterized by Mx:MT as it will certainly use operations of M, but what seems artificial is the declaration of Mt in the signature QT (and hence in the functor QF). Intuitively, I would say that the signature QT refers to the type t declared in the signature MT, not in the structure M. Is there a simpler way to do this ? I suspect my solution is too complicate, but I couldn't find better... -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs