Ok, I got it. Thank you all for the help, Jacky On 22/07/2010 08:47, Jacques Garrigue wrote: > No, I'm saying that this kind of syntax overloading occurs in Haskell. > However, since Haskell has no functors, you cannot do that either. > > Again, what you ask for is possible in ocaml, and in a particularly clean > way in 3.12. Namely, Jeremy Yallop's second example does exactly what you want. > The only difference is the syntax: you write "ABC with module M := IntList" > rather than "ABC(IntList)". Different concepts get different syntax. > > Jacques > > On 2010/07/22, at 15:38, Dumitru Potop-Butucaru wrote: > > >> So, what you say is that this way of manipulating >> module types can be done in Haskell? >> >> Yours, >> Jacky >> >> >> On 22/07/2010 08:18, Jacques Garrigue wrote: >> >>> From: Dumitru Potop-Butucaru >>> >>> >>>> However, I still did not understand this statement of >>>> Jeremy Yallop: >>>> >>>> >>>>>> module type Abc = >>>>>> functor (M:Simple) -> >>>>>> sig >>>>>> val x : M.t >>>>>> end >>>>>> >>>>>> >>>>>> >>>>> You're trying to treat Abc as a functor from signatures to signatures >>>>> (i.e. as a parameterised signature). In fact, it's something quite >>>>> different: it's the *type* of a functor from structures to structures. >>>>> >>>>> >>>>> >>>> If I understand well, what I try to do is impossible for >>>> some deep theoretical reason. Can someone explain this >>>> to me, or point me to a relevant paper explaining it? >>>> >>>> >>> I think this is not a question of impossibility, rather of >>> misunderstanding of the relation between modules and signatures. >>> A module type describes modules, it does not replace them. >>> In particular, in another mail you asked for the construct: >>> >>> module type MyModuleType(Param:ParamType) = sig ... end >>> >>> But this just doesn't make sense. The type of a functor is not a >>> functor between module types. Just like the type "t1 * t2" describes >>> pairs of values of type t1 and t2, but it is not itself a pair of >>> types, but rather a product. >>> >>> Note of course that one might want to play on the conceptual >>> similarity to write the two in the same way. Haskell does that a lot, >>> writing (t1,t2) for the product of the types t1 and t2. But if >>> you look at languages like Coq, where types are also values, this >>> kind of overloading seems dangerous. >>> >>> Another similar misunderstanding is when you write >>> include Abc(module type of IntSet) >>> This statement is doubly wrong: first you cannot apply a module type, >>> but even if Abc were a functor, it could only be applied to a module, >>> not a module type. >>> Others have explained how you can do what you intended, in two >>> different ways. >>> The classical way is to use a real functor, returning a signature >>> enclosed in a module, since there is no way to return a signature >>> alone. There is nothing against applying functors inside signatures. >>> The new solution in 3.12 is to use a variant of the "with" >>> construct, which does exactly what you want, i.e. it turns a >>> signature into a "function" returning a signature. >>> >>> Hope this helps, >>> >>> Jacques Garrigue >>> >>> >>> >>> >> >> > > >