Advertisement

A type system for a lambda calculus with assignments

  • Kung Chen
  • Martin Odersky
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 789)

Abstract

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.

Keywords

Induction Hypothesis Type System Operational Semantic Type Scheme State Transformer 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [AM87]
    Andrew W. Appel and David B. MacQueen. A standard ML compiler. In Functional Programming and Computer Architecture, pages 301–324, August 1987. LNCS 274.Google Scholar
  2. [Bar84]
    H. Barendregt. The Lambda Calculus: Its Syntax and Semantics, volume 103 of Studies in Logic and the Foundations of Mathematics. North-Holland, 1984.Google Scholar
  3. [Dam85]
    Luis Damas. Type assignment in programming languages. PhD thesis, Department of Computer Science, Edinburgh University, April 1985.Google Scholar
  4. [DM82]
    L. Damas and Robin Milner. Principal type schemes for functional programs. In Proceedings of the Ninth ACM Symposium on Principles of Programming Languages, pages 207–212, January 1982.Google Scholar
  5. [HMV93]
    My Hoang, John Mitchell, and Ramesh Viswanathan. Standard ML-NJ weak polymorphism and imperative constructs. In Eighth Annual IEEE Symposium on Logic in Computer Science, pages 15–25, June 1993.Google Scholar
  6. [Ler93]
    Xavier Leroy. Polymorphism by name for references and continuations. In Proc. of 20th ACM Symp. on Principles of Programming Languages, pages 220–231, January 1993.Google Scholar
  7. [LW91]
    Xavier Leroy and Pierre Weis. Polymorphic type inference and assignment. In Proc. of the 18th ACM Symp. on Principles of Programming Languages, pages 291–302, January 1991.Google Scholar
  8. [Mai93]
    Harry G. Mairson. Quantifier elimination and parametric polymorphism in programming languages. To appear in the J. of Functional Programming, 1993.Google Scholar
  9. [Mil78]
    Robin Milner. A theory of type polymorphism in programming. J. Computer and System Sciences, 17:348–375, 1978.Google Scholar
  10. [ORH93]
    Martin Odersky, Dan Rabin, and Paul Hudak. Call by name, assignment, and the lambda calculus. In Proc. of 20th ACM Symp. on Principles of Programming Languages, January 1993.Google Scholar
  11. [Rey88]
    John C.Reynolds. Preliminary design of the programming language forsythe. Technical Report CMU-CS-88-159, Carnegie Mellon University, June 1988.Google Scholar
  12. [SRI91]
    V. Swarup, U. Reddy, and E. Ireland. Assignments for applicative languages. In J. Hughes, editor, Proc. 5th ACM Conf. on Functional Programming and Computer Architecture, pages 192–214, August 1991. LNCS 582.Google Scholar
  13. [TJ93]
    Jean-Pierre Talpin and Pierre Jouvelot. Polymorphic type, region and effect inference. To appear in the J. of Functional Programming, 1993.Google Scholar
  14. [TJ94]
    Jean-Pierre Talpin and Pierre Jouvelot. The type and effect discipline. To appear in the J. of Information and Computation, 1994.Google Scholar
  15. [Tof90]
    Mads Tofte. Type inference for polymorphic references. Information and Computation, 89(1):1–34, November 1990.Google Scholar
  16. [Wad92]
    Philip Wadler. The essence of functional programming. In Proc. 19th ACM Symposium on Principles of Programming Languages, pages 1–14, January 1992.Google Scholar
  17. [WF92]
    Andrew K. Wright and Matthias Felleisen. A syntactic approach to type soundness. Technical Report TR91-160, Department of Computer Science, Rice University, March 1992.Google Scholar
  18. [WF93]
    Stephen Weeks and Matthias Felleisen. On the orthogonality of assignments and procedures in Algol. In Proc. of 20th ACM Symp. on Principles of Programming Languages, January 1993.Google Scholar
  19. [Wri92]
    Andrew K. Wright. Typing references by effect inferences. In B. Krieg-Brückner, editor, Prod. European Symposium on Programming, pages 473–491, February 1992. LNCS 582.Google Scholar
  20. [Wri93]
    Andrew K. Wright. Polymorphism for imperative languages without imperative types. Technical Report TR93-200, Rice University, February 1993.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1994

Authors and Affiliations

  • Kung Chen
    • 1
  • Martin Odersky
    • 2
  1. 1.Dept. of Computer ScienceYale UniversityNew HavenUSA
  2. 2.Dept. of InformaticsUniversität KarlsruheKarlsruheGermany

Personalised recommendations