Abstract
We classify programming languages according to evaluation order: each language fixes one evaluation order as the default, making it transparent to program in that evaluation order, and troublesome to program in the other. This paper develops a type system that is impartial with respect to evaluation order. Evaluation order is implicit in terms, and explicit in types, with by-value and by-name versions of type connectives. A form of intersection type quantifies over evaluation orders, describing code that is agnostic over (that is, polymorphic in) evaluation order. By allowing such generic code, programs can express the by-value and by-name versions of a computation without code duplication. We also formulate a type system that only has by-value connectives, plus a type that generalizes the difference between by-value and by-name connectives: it is either a suspension (by name) or a "no-op" (by value). We show a straightforward encoding of the impartial type system into the more economical one. Then we define an elaboration from the economical language to a call-by-value semantics, and prove that elaborating a well-typed source program, where evaluation order is implicit, produces a well-typed target program where evaluation order is explicit. We also prove a simulation between evaluation of the target program and reductions (either by-value or by-name) in the source program. Finally, we prove that typing, elaboration, and evaluation are faithful to the type annotations given in the source program: if the programmer only writes by-value types, no by-name reductions can occur at run time.
- A. Asperti. Integrating strict and lazy evaluation: the λ sl -calculus. In Programming Language Implementation and Logic Programming, volume 456 of LNCS, pages 238–254. Springer, 1990. Google Scholar
Digital Library
- H. Barendregt, M. Coppo, and M. Dezani-Ciancaglini. A filter lambda model and the completeness of type assignment. J. Symbolic Logic, 48(4):931–940, 1983.Google Scholar
Cross Ref
- G. Barthe. Implicit coercions in type systems. In Proc. TYPES ’95, volume 1158 of LNCS, pages 1–15, 1996. Google Scholar
Digital Library
- P. Bernays. Review of “Some Properties of Conversion” by Alonzo Church and J.B. Rosser. J. Symbolic Logic, 1:74–75, 1936.Google Scholar
- V. Breazu-Tannen, T. Coquand, C. A. Gunter, and A. Scedrov. Inheritance as implicit coercion. Information and Computation, 93(1):172–221, 1991. Google Scholar
Digital Library
- S. Chang. On the Relationship Between Laziness and Strictness. PhD thesis, Northeastern University, 2014.Google Scholar
Cross Ref
- Y. Chen, J. Dunfield, M. A. Hammer, and U. A. Acar. Implicit self-adjusting computation for purely functional programs. J. Functional Programming, 24(1):56–112, 2014.Google Scholar
Cross Ref
- M. Coppo, M. Dezani-Ciancaglini, and B. Venneri. Functional characters of solvable terms. Zeitschrift f. math. Logik und Grundlagen d. Math., 27:45–58, 1981.Google Scholar
- R. Davies. Practical Refinement-Type Checking. PhD thesis, Carnegie Mellon University, 2005. CMU-CS-05-110. R. Davies and F. Pfenning. Intersection types and computational effects. In ICFP, pages 198–208, 2000. Google Scholar
Digital Library
- J. Dunfield. Elaborating intersection and union types. J. Functional Programming, 24(2–3):133–165, 2014.Google Scholar
Cross Ref
- J. Dunfield. Elaborating evaluation-order polymorphism, 2015. Extended version with appendices. arXiv:1504.07680 {cs.PL}. J. Dunfield and N. R. Krishnaswami. Complete and easy bidirectional typechecking for higher-rank polymorphism. In ICFP, 2013. arXiv:1306.6032 {cs.PL}. J. Dunfield and F. Pfenning. Type assignment for intersections and unions in call-by-value languages. In FoSSaCS, pages 250–266, 2003. Google Scholar
Digital Library
- J. Dunfield and F. Pfenning. Tridirectional typechecking. In Principles of Programming Languages, pages 281–292, 2004. Google Scholar
Digital Library
- T. Freeman and F. Pfenning. Refinement types for ML. In PLDI, pages 268–277, 1991. Google Scholar
Digital Library
- D. P. Friedman and D. S. Wise. CONS should not evaluate its arguments. In ICALP, pages 257–284. Edinburgh Univ. Press, 1976.Google Scholar
- A. Frisch, G. Castagna, and V. Benzaken. Semantic subtyping. In Logic in Computer Science, 2002. Google Scholar
Digital Library
- P. Henderson and J. H. Morris, Jr. A lazy evaluator. In Principles of Programming Languages, pages 95–103. ACM, 1976. Google Scholar
Digital Library
- J. R. Hindley. Types with intersection: An introduction. Formal Aspects of Computing, 4:470–486, 1992.Google Scholar
Digital Library
- D. Leivant. Typing and computational properties of lambda expressions. Theoretical Computer Science, 44(0):51–68, 1986. Google Scholar
Digital Library
- P. B. Levy. Call-by-push-value: A subsuming paradigm. In Typed Lambda Calculi and Applications, pages 228–243. Springer, 1999. Google Scholar
Digital Library
- R. Milner, M. Tofte, R. Harper, and D. MacQueen. The Definition of Standard ML (Revised). MIT Press, 1997. Google Scholar
Digital Library
- P. Naur et al. Report on the algorithmic language ALGOL 60. Comm. ACM, 3(5):299–314, 1960. Google Scholar
Digital Library
- B. C. Pierce. Types and Programming Languages. MIT Press, 2002. Google Scholar
Digital Library
- B. C. Pierce and D. N. Turner. Local type inference. ACM Trans. Prog. Lang. Systems, 22:1–44, 2000. Google Scholar
Digital Library
- G. Plotkin. Call-by-name, call-by-value, and the lambda calculus. Theoretical Computer Science, 1:125–159, 1975.Google Scholar
Cross Ref
- J. C. Reynolds. Design of the programming language Forsythe. Technical Report CMU-CS-96-146, Carnegie Mellon University, 1996.Google Scholar
- N. Swamy, M. Hicks, and G. M. Bierman. A theory of typed coercions and its applications. In ICFP, pages 329–340, 2009. Google Scholar
Digital Library
- P. Wadler, W. Taha, and D. MacQueen. How to add laziness to a strict language without even being odd. In Workshop on Standard ML, 1998. http://homepages.inf.ed.ac.uk/ wadler/papers/lazyinstrict/lazyinstrict.ps. C. Wadsworth. Semantics and Pragmatics of the lambda-Calculus. PhD thesis, University of Oxford, 1971.Google Scholar
- A. Warth. LazyJ: Seamless lazy evaluation in Java. In FOOL, 2007.Google Scholar
- foolwood07.cs.uchicago.edu/program/warth.pdf. R. L. Wexelblat, editor. History of Programming Languages I. ACM, 1981.Google Scholar
- A. K. Wright. Simple imperative polymorphism. Lisp and Symbolic Computation, 8(4):343–355, 1995. Google Scholar
Digital Library
- H. Xi. Dependent Types in Practical Programming. PhD thesis, Carnegie Mellon University, 1998. Google Scholar
Digital Library
Index Terms
Elaborating evaluation-order polymorphism
Recommendations
Elaborating evaluation-order polymorphism
ICFP 2015: Proceedings of the 20th ACM SIGPLAN International Conference on Functional ProgrammingWe classify programming languages according to evaluation order: each language fixes one evaluation order as the default, making it transparent to program in that evaluation order, and troublesome to program in the other. This paper develops a type ...
Polymorphic functions with set-theoretic types: part 1: syntax, semantics, and evaluation
POPL '14: Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesThis article is the first part of a two articles series about a calculus with higher-order polymorphic functions, recursive types with arrow and product type constructors and set-theoretic type connectives (union, intersection, and negation).
In this ...
Polymorphic functions with set-theoretic types: part 1: syntax, semantics, and evaluation
POPL '14This article is the first part of a two articles series about a calculus with higher-order polymorphic functions, recursive types with arrow and product type constructors and set-theoretic type connectives (union, intersection, and negation).
In this ...






Comments