Browse thread
small typing problem with modules ...
-
Pietro Abate
-
Julien Signoles
- Pietro Abate
- Andreas Rossberg
-
Julien Signoles
[
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: | 2009-05-26 (13:12) |
From: | Pietro Abate <Pietro.Abate@p...> |
Subject: | Re: [Caml-list] small typing problem with modules ... |
On Tue, May 26, 2009 at 02:37:18PM +0200, Julien Signoles wrote: > >but then I'm a bit lost putting all this together ... > >I know I'm close ... a small hint ? > Hum, module types cannot be parameterized. If you want to use a functor > signature, you can write the following : uhmmm I was wondering ... :) > ===== > module type T = > functor (Extra : A.Extra) -> > functor (A : A.T with type extra = Extra.t) -> > sig val f : A.extra -> unit end > > module Make : T > > open A > val f : extra -> unit > ===== > > But I'm pretty sure that is not really what is expected... > However why cannot you just add an another abstract type in your > signature like below? well it does not solve the duplication problem as I cannot write something like : include T (A.ExtraDefault) (A) as we don't have functorized module types as you pointed out. you just moved the functor signature to the type T ... > ===== > module type T = sig > type extra > val f : extra -> unit > end > > module Make(Extra : A.Extra)(A : A.T with type extra = Extra.t) > : T with type extra = A.extra > > open A > val f : extra -> unit > ===== ok, I can do that, but it would be still annoying as the module A might contain a lot of types that I would need to add to the signature T in b.mli . Something like : module type T = sig type a type b ... type n val fa : a -> unit val fb : b -> unit ... val fn : n -> unit end but this should solve the duplication problem as I can now write something like include T with type extra = A.extra ( .... and all other types .... ) I'm still not really satisfied with this solution, but I'm now worried that with the current syntax is just not possible to solve my problem... thanks :) pp