blob: cf43ae764862cc5a2504605ad3e9713f2ee007c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
(Introduced in OCaml 4.02)
\begin{syntax}
module-expr:
...
| 'functor' '()' '->' module-expr
| module-expr '()'
;
definition:
...
| 'module' module-name { '(' module-name ':' module-type ')' || '()' }
[ ':' module-type ] \\ '=' module-expr
;
module-type:
...
| ['functor'] '()' '->' module-type
;
specification:
...
| 'module' module-name { '(' module-name ':' module-type ')' || '()' }
':' module-type
;
\end{syntax}
A generative functor takes a unit "()" argument.
In order to use it, one must necessarily apply it to this unit argument,
ensuring that all type components in the result of the functor behave
in a generative way, {\em i.e.} they are different from types obtained
by other applications of the same functor.
This is equivalent to taking an argument of signature "sig end", and always
applying to "struct end", but not to some defined module (in the
latter case, applying twice to the same module would return identical
types).
As a side-effect of this generativity, one is allowed to unpack
first-class modules in the body of generative functors.
|