functor F () = struct datatype t = T end structure S1 = F () structure S2 = F () val _: S1.t -> S2.t = fn x => x
Generativity also means that two different datatype declarations define different types, even if they define identical constructors. The following program does not type check due to this.
datatype t = A | B val a1 = A datatype t = A | B val a2 = A val _ = if true then a1 else a2