Browse thread
Module type of a structure returned by functor
-
Dawid Toton
-
Dawid Toton
- Vincent Aravantinos
- rossberg@m...
- Jacques Garrigue
-
Dawid Toton
[
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: | 2010-04-26 (16:54) |
From: | rossberg@m... |
Subject: | Re: [Caml-list] Re: Module type of a structure returned by functor |
Dawid Toton <d0@wp.pl> wrote: > I've found that I have more fundamental problem. What is the exact > meaning of the following line? > > module type Foo = functor (X:X) -> sig val foo : X.t end > > (1) Foo is not a functor, but it is a type of some functors that map > modules to modules > (2) Foo is a mapping from modules to module types > > Currently I think that it (1) is true and (2) is false. Let me know if > I'm wrong. That's right. A construct for (2), sometimes referred to as "parameterized signatures", does not exist in OCaml directly. However, you can encode it using a functor with a nested signature in its result: module FooOf (X : X) = struct module type S = sig val foo : X.t end end Now, for example: module F (X : X) (Y : FooOf(X).S) = ... > It means that there is no easy way to get module type of what results > from functor application. I think that the solution is to separately > define signature of results of the functor and use "with type" clauses > to recreate all result module types that are needed. > > This is not very bad, but I'm still wondering if "module type of..." of > 3.12 will provide elegant solution for this. Interesting, it looks like it may. I wasn't aware that singleton signatures will be coming in 3.12 - nice. /Andreas