Standard ML Weak Polymorphism Can Be Sound

Adding ML-style references to a Hindley-Milner polymorphic type system is troublesome because such a system is unsound with naive polymorphic generalization of reference types. Tofte introduced a distinction between imperative and applicative type variables, such that applicative type variables are never in reference types, that provides a simple static analysis of which type variables may be polymorphically generalized. MacQueen''s weak type variables generalize imperative type variables with a counter called a strength. The finer distinction allows a more accurate analysis of when a reference may be created, and thus which type variables may be generalized. Unfortunately, weak polymorphism has been presented only as part of the implementation of the SML/NJ compiler, not as a formal type system. As a result, it is not well understood, as its more subtle points are not well known. Furthermore, while versions of the implementation have repeatedly been shown unsound, the concept has not been proven sound or unsound. We present several formal systems of weak polymorphism, show their connection to the SML/NJ implementation, and show the soundness of most of these systems.

[1]  Robert Harper,et al.  A Simplified Account of Polymorphic References , 1994, Inf. Process. Lett..

[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]  Xavier Leroy,et al.  Polymorphic type inference and assignment , 1991, POPL '91.

[4]  Ramesh Viswanathan,et al.  Standard ML-NJ weak polymorphism and imperative constructs , 1993, [1993] Proceedings Eighth Annual IEEE Symposium on Logic in Computer Science.

[5]  A. K. Wmght Polymorphism for imperative languages without imperative types , 1993 .

[6]  J. Roger Hindley,et al.  Introduction to combinators and λ-calculus , 1986, Acta Applicandae Mathematicae.

[7]  Xavier Leroy,et al.  Polymorphic typing of an algorithmic language , 1992 .

[8]  Luís Damas Type assignment in programming languages , 1984 .

[9]  M. Tofte Operational Semantics and Polymorphic Type Inference , 1988 .

[10]  Pierre Jouvelot,et al.  Polymorphic type, region and effect inference , 1992, Journal of Functional Programming.

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

[12]  James W. O'Toole Type Abstraction Rules for References: A Comparison of Four which have Achieved Notoriety , 1991 .