The explanation in Section 8.21 Generative Functors of the OCaml Manual gives the impression that using ()
or struct end
as functor argument make a functor generative. The code below makes me suspect that any functor argument that is not a named module makes a functor generative. What are the details here?
module X (E: sig type x end): sig
type t
val t: t
end = struct
type t = int
let t = 0
end
module X1 = X (struct type x = int end)
module X2 = X (struct type x = int end)
module E = struct
type x = int
end
module X1' = X (E)
module X2' = X (E)
- Types
X1.t
andX2.t
are incompatible – X is generative - Types
X1'.t
anfX2'.t
are compatible – X is not generative