8.16 Generative functors

(Introduced in OCaml 4.02)

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

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 behavein a generative way, i.e. they are different from types obtainedby other applications of the same functor.This is equivalent to taking an argument of signature sig end, and alwaysapplying to struct end, but not to some defined module (in thelatter case, applying twice to the same module would return identicaltypes).

As a side-effect of this generativity, one is allowed to unpackfirst-class modules in the body of generative functors.