A Type System for a Lambda Calculus with Assignments

We present a Hindley/Milner-style polymorphic type system for λvar, an extension of the call-by-name λ-calculus with mutable variables and assignments. To match λvar's explicit distinction between functional and imperative worlds, the type universe is stratified into two layers: one for applicative expressions and one for imperative state transformers. In inferring types for λvar-terms, the type system performs a simple effect analysis to statically verify the safety of coercing a state transformer to a pure value. We prove the soundness of the type system with respect to λvar's untyped reduction semantics so that any well-typed program will evaluate to an answer, provided the evaluation terminates. We also discuss some practical aspects of the type system and present a type checker based on the well-known W algorithm.

[1]  Robin Milner,et al.  Principal type-schemes for functional programs , 1982, POPL '82.

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

[3]  Harry G. Mairson Quantifier elimination and parametric polymorphism in programming languages , 1992, Journal of Functional Programming.

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

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

[6]  Philip Wadler,et al.  The essence of functional programming , 1992, POPL '92.

[7]  Henk Barendregt,et al.  The Lambda Calculus: Its Syntax and Semantics , 1985 .

[8]  Matthias Felleisen,et al.  On the orthogonality of assignments and procedures in Algol , 1993, POPL '93.

[9]  Andrew Wright Polymorphism for Imperative Languages without Imperative Types , 1993 .

[10]  Paul Hudak,et al.  Call by name, assignment, and the lambda calculus , 1993, POPL '93.

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

[12]  Luís Damas,et al.  Type assignment in programming languages , 1984 .

[13]  John C. Reynolds,et al.  Preliminary design of the programming language Forsythe , 1988 .

[14]  Matthias Felleisen,et al.  A Syntactic Approach to Type Soundness , 1994, Inf. Comput..

[15]  Ramesh Viswanathan,et al.  Standard ML-NJ Weak Polymorphism and Imperative Constructs , 1996, Inf. Comput..

[16]  Xavier Leroy,et al.  Polymorphism by name for references and continuations , 1993, POPL '93.

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

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

[19]  Vipin Swarup,et al.  Assignments for Applicative Languages , 1991, FPCA.

[20]  Pierre Jouvelot,et al.  The Type and Effect Discipline , 1994, Inf. Comput..