re free type variables in SML

Stephen Weeks MLton@sourcelight.com
Fri, 24 Aug 2001 13:11:25 -0700


> I thought that the range of program text a compiler must look at to infer a
> type wasn't layed down.

The only cases I can think of that "range" matters is in overloading resolution
and in unconstrained, yet unquantifiable (due to expansiveness) types.  If there
are others you can think of, please say them.

For overloading, there is section E, page 71, which says that the "surrounding
text is no larger than the smallest enclosing structure level declaration", but
may be smaller.  MLton actually violates this because it uses the entire
program.  The new front end will use the largest allowable scope.

For unconstrained types (as in "val id = (fn x => x) (fn x => x)"), we are still
discussing it on comp.lang.ml, but my reading is that the scope that one must
use is the entire enclosing topdec.