[MLton] free type variables in datatype decs

Andreas Rossberg AndreasRossberg@web.de
Thu, 3 Feb 2005 22:08:09 +0100


> Disallow free variables in datatypes:
>
>  + Simple syntactic rule.
>  + Other SML compilers do it.  Hence, the usual portability arguments
>    apply.

I have another, deeper technical argument: allowing val-bound type variables
in type declarations destroys a very strong design invariant of SML, namely
that the denotation of an explicit type declaration never depends on any
implicitly passed type information.

In the implementation of Alice ML, which incorporates a form of module-level
dynamics, this is very important. It allows us to employ the usual
type-erasing compilation strategy for polymorphic functions, although we
have to maintain dynamic type information for all explicit type
declarations. With the more liberal rule this would no longer work, and we
needed a costly type-passing translation for all polymorphic functions. (I
can elaborate on this if there is interest.)

Now, this does not affect MLton per se, but probably serves as an additional
data point.