[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Tony Edgin <edgin@s...> |
| Subject: | Re: [Caml-list] My wishlist: DRY modules |
This is a reply to an old email, but it reflects something I just learned. On Thu, 14 Oct 2004 11:00, Brian Hurt wrote: > I'm doing some work with modules, and I'm learning some of their > annoyances. Number one is having to repeat module type definitions. For > example, say you have a file foo. In foo.mli, you have: > > module type T = sig > type s > val needed : ... > end > > module type S = sig > type t > val doit : ... > val orelse : ... > end > > module Make(Arg: T) : S with type t = Arg.s > > So far, so good, but now in foo.ml you need to replicate the definitions > of *both* T and S: > > module type T = sig > type s > val needed : ... > end > > module type S = sig > type t > val doit : ... > val orelse : ... > end > > module Make(Arg: T) = struct > type t = Arg.s > let doit = ... > let orelse = ... > end One partial solution would be to do the following in your foo.ml file. module type T = Foo.T module type S = Foo.S module Make(Arg: T) = struct type t = Arg.s let doit = ... let orelse = ... end ;; cheers. -- Tony Edgin CARP