skip to main content
research-article

Elaborating evaluation-order polymorphism

Published:29 August 2015Publication History
Skip Abstract Section

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.

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarCross RefCross Ref
  3. G. Barthe. Implicit coercions in type systems. In Proc. TYPES ’95, volume 1158 of LNCS, pages 1–15, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. P. Bernays. Review of “Some Properties of Conversion” by Alonzo Church and J.B. Rosser. J. Symbolic Logic, 1:74–75, 1936.Google ScholarGoogle Scholar
  5. V. Breazu-Tannen, T. Coquand, C. A. Gunter, and A. Scedrov. Inheritance as implicit coercion. Information and Computation, 93(1):172–221, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. S. Chang. On the Relationship Between Laziness and Strictness. PhD thesis, Northeastern University, 2014.Google ScholarGoogle ScholarCross RefCross Ref
  7. 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 ScholarGoogle ScholarCross RefCross Ref
  8. 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 ScholarGoogle Scholar
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. J. Dunfield. Elaborating intersection and union types. J. Functional Programming, 24(2–3):133–165, 2014.Google ScholarGoogle ScholarCross RefCross Ref
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. J. Dunfield and F. Pfenning. Tridirectional typechecking. In Principles of Programming Languages, pages 281–292, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. T. Freeman and F. Pfenning. Refinement types for ML. In PLDI, pages 268–277, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. D. P. Friedman and D. S. Wise. CONS should not evaluate its arguments. In ICALP, pages 257–284. Edinburgh Univ. Press, 1976.Google ScholarGoogle Scholar
  15. A. Frisch, G. Castagna, and V. Benzaken. Semantic subtyping. In Logic in Computer Science, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. P. Henderson and J. H. Morris, Jr. A lazy evaluator. In Principles of Programming Languages, pages 95–103. ACM, 1976. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. J. R. Hindley. Types with intersection: An introduction. Formal Aspects of Computing, 4:470–486, 1992.Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. D. Leivant. Typing and computational properties of lambda expressions. Theoretical Computer Science, 44(0):51–68, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. P. B. Levy. Call-by-push-value: A subsuming paradigm. In Typed Lambda Calculi and Applications, pages 228–243. Springer, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. R. Milner, M. Tofte, R. Harper, and D. MacQueen. The Definition of Standard ML (Revised). MIT Press, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. P. Naur et al. Report on the algorithmic language ALGOL 60. Comm. ACM, 3(5):299–314, 1960. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. B. C. Pierce. Types and Programming Languages. MIT Press, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. B. C. Pierce and D. N. Turner. Local type inference. ACM Trans. Prog. Lang. Systems, 22:1–44, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. G. Plotkin. Call-by-name, call-by-value, and the lambda calculus. Theoretical Computer Science, 1:125–159, 1975.Google ScholarGoogle ScholarCross RefCross Ref
  25. J. C. Reynolds. Design of the programming language Forsythe. Technical Report CMU-CS-96-146, Carnegie Mellon University, 1996.Google ScholarGoogle Scholar
  26. N. Swamy, M. Hicks, and G. M. Bierman. A theory of typed coercions and its applications. In ICFP, pages 329–340, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle Scholar
  28. A. Warth. LazyJ: Seamless lazy evaluation in Java. In FOOL, 2007.Google ScholarGoogle Scholar
  29. foolwood07.cs.uchicago.edu/program/warth.pdf. R. L. Wexelblat, editor. History of Programming Languages I. ACM, 1981.Google ScholarGoogle Scholar
  30. A. K. Wright. Simple imperative polymorphism. Lisp and Symbolic Computation, 8(4):343–355, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. H. Xi. Dependent Types in Practical Programming. PhD thesis, Carnegie Mellon University, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Elaborating evaluation-order polymorphism

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 50, Issue 9
        ICFP '15
        September 2015
        436 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2858949
        • Editor:
        • Andy Gill
        Issue’s Table of Contents
        • cover image ACM Conferences
          ICFP 2015: Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming
          August 2015
          436 pages
          ISBN:9781450336697
          DOI:10.1145/2784731

        Copyright © 2015 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 29 August 2015

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!