First of all you should follow the link, provided by @didierc and read about weak type variables, so that you understand why they exist and when they come into play.
Usually, there is nothing bad in weak type variables, especially, when you're scripting. You can strengthen them by using eta-expansion (i.e., by enumerating all arguments of a partially applied function, e.g., substituting List.hd
with fun x -> List.hd x
).
Weak variables are not allowed everywhere, in particular, they cannot escape a module, i.e., they can't occur in a module signature. So that a value, that has a weak type can be only accessed from inside the module where it is defined. That lexically guarantees, that a variable will have only one type, that will be assigned as soon as it is accessed.
When you write an ml
file, you create a part of a compilation unit. The compilation unit is composed from the implementation (ml
file) and interface (mli
file). If you omit the latter, then compiler will infer the interface automatically, exporting all fields of a module. In that case it will also export weak variables.
With all that said, you can just create an empty progetto.mli
file, that will close the Progetto
module, and no weak variables will leak it. So that the compiler will be happy, as nobody can break the type system.