Chapter 8 Language extensions
This chapter describes language extensions and convenience features that are implemented in OCaml, but not described in the OCaml reference manual.
15 Generative functors
(Introduced in OCaml 4.02)
|
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, 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.