Standard ML-NJ Weak Polymorphism and Imperative Constructs

Standard ML of New Jersey (SML-NJ) uses weak-type variables to restrict the polymorphic use of functions that may allocate reference cells, manipulate continuations, or use exceptions. However, the type system used in the SML-NJ compiler has not been presented in a form other than source code and has not been proved correct. A type system, in the form of typing rules and an equivalent algorithm, that appears to subsume the implemented algorithm is presented. Both use type variables of only a slightly more general nature than the compiler. One insight in the analysis is that the indexed type of a free variable is used in two ways, once in describing the applicative behavior of the variable itself and once in describing the larger term containing the variable. Taking this into account, an application rule that is more general than SML-NJ is formulated for applications of polymorphic functions to imperative arguments. The soundness of the type system is proved for imperative code using operational semantics. >

[1]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[2]  Pierre Jouvelot,et al.  The type and effect discipline , 1992, [1992] Proceedings of the Seventh Annual IEEE Symposium on Logic in Computer Science.

[3]  R. Hindley The Principal Type-Scheme of an Object in Combinatory Logic , 1969 .

[4]  Andrew Koenig An anecdote about ML type inference , 1994 .

[5]  Xavier Leroy,et al.  Polymorphic type inference and assignment , 1991, POPL '91.

[6]  Andrew W. Appel,et al.  A Standard ML compiler , 1987, FPCA.

[7]  Pierre Jouvelot,et al.  Algebraic reconstruction of types and effects , 1991, POPL '91.

[8]  Andrew K. Wright Typing References by Effect Inference , 1992, ESOP.

[9]  Andrew W. Appel,et al.  Standard ML of New Jersey , 1991, PLILP.

[10]  Mads Tofte,et al.  Type Inference for Polymorphic References , 1990, Inf. Comput..