Abstract
A long-standing shortcoming of statically typed functional languages is that type checking does not rule out pattern-matching failures (run-time match exceptions). Refinement types distinguish different values of datatypes; if a program annotated with refinements passes type checking, pattern-matching failures become impossible. Unfortunately, refinement is a monolithic property of a type, exacerbating the difficulty of adding refinement types to nontrivial programs.
Gradual typing has explored how to incrementally move between static typing and dynamic typing. We develop a type system of gradual sums that combines refinement with imprecision. Then, we develop a bidirectional version of the type system, which rules out excessive imprecision, and give a type-directed translation to a target language with explicit casts. We prove that the static sublanguage cannot have match failures, that a well-typed program remains well-typed if its type annotations are made less precise, and that making annotations less precise causes target programs to fail later. Several of these results correspond to criteria for gradual typing given by Siek et al. (2015).
Supplemental Material
Available for Download
Appendix with definitions, lemmas, and proofs, omitted from the POPL 2017 paper "Sums of Uncertainty: Refinements Go Gradual" for space reasons.
- Martín Abadi, Luca Cardelli, Benjamin Pierce, and Gordon Plotkin. Dynamic typing in a statically typed language. ACM Trans. Prog. Lang. Syst., 13(2):237–268, 1991. Google Scholar
Digital Library
- Amal Ahmed, Robert Bruce Findler, Jeremy G. Siek, and Philip Wadler. Blame for all. In Principles of Programming Languages, pages 201–214, 2011.Google Scholar
- Esteban Allende, Johan Fabry, Ronald Garcia, and Éric Tanter. Confined gradual typing. In OOPSLA, pages 251–270, 2014. Google Scholar
Digital Library
- Felipe Bañados Schwerter, Ronald Garcia, and Éric Tanter. A theory of gradual effect systems. In ICFP, pages 283–295, 2014.Google Scholar
- Thierry Coquand. An algorithm for type-checking dependent types. Science of Computer Programming, 26(1–3):167–177, 1996. Google Scholar
Digital Library
- Rowan Davies. Practical Refinement-Type Checking. PhD thesis, Carnegie Mellon University, 2005. CMU-CS-05-110. Rowan Davies and Frank Pfenning. Intersection types and computational effects. In ICFP, pages 198–208, 2000. Google Scholar
Digital Library
- Michael Dummett. The Logical Basis of Metaphysics. Harvard University Press, 1991. The William James Lectures, 1976.Google Scholar
- Jana Dunfield. A Unified System of Type Refinements. PhD thesis, Carnegie Mellon University, 2007. CMU-CS-07-129. Jana Dunfield. Elaborating evaluation-order polymorphism. In Int'l Conf. Functional Programming, 2015. arXiv:1504.07680 {cs.PL}. Jana Dunfield and Neelakantan R. Krishnaswami. Complete and easy bidirectional typechecking for higher-rank polymorphism. In ICFP, 2013. arXiv:1306.6032 {cs.PL}. Jana Dunfield and Frank Pfenning. Tridirectional typechecking. In Principles of Programming Languages, pages 281-292, 2004. Google Scholar
Digital Library
- Tim Freeman. Refinement Types for ML. PhD thesis, Carnegie Mellon University, 1994. CMU-CS-94-110. Tim Freeman and Frank Pfenning. Refinement types for ML. In Programming Language Design and Implementation, pages 268–277, 1991. Google Scholar
Digital Library
- Ronald Garcia and Matteo Cimini. Principal type schemes for gradual programs. In Principles of Programming Languages, pages 303–315, 2015. Google Scholar
Digital Library
- Ronald Garcia, Alison M. Clark, and Éric Tanter. Abstracting gradual typing. In Principles of Programming Languages, pages 429–442, 2016. Google Scholar
Digital Library
- Gerhard Gentzen. Untersuchungen über das logische Schließen. Mathematische Zeitschrift, 39:176–210, 405–431, 1934. English translation, Investigations into logical deduction, in M. Szabo, editor, Collected papers of Gerhard Gentzen (North-Holland, 1969), pages 68–131. Ruud Koot and Jurriaan Hage. Type-based exception analysis for non-strict higher-order functional languages with imprecise exception semantics. In Proceedings of the 2015 Workshop on Partial Evaluation and Program Manipulation, pages 127–138, 2015. Google Scholar
Digital Library
- Per Martin-Löf. On the meanings of the logical constants and the justifications of the logical laws. Nordic Journal of Philosophical Logic, 1(1):11–60, 1996. Notes for lectures given in 1983 in Siena, Italy. Trevor L. McDonell, Timothy A. K. Zakian, Matteo Cimini, and Ryan R. Newton. Ghostbuster: A tool for simplifying and converting GADTs. In ICFP, pages 338–350, 2016.Google Scholar
- Robin Milner, Mads Tofte, Robert Harper, and David MacQueen. The Definition of Standard ML (Revised). MIT Press, 1997. Google Scholar
Digital Library
- Frank Pfenning. Lecture notes on harmony. Lecture notes for 15–317: Constructive Logic, Carnegie Mellon University, September 2009.Google Scholar
- www.cs.cmu.edu/ ∼fp/courses/15317f09/lectures/03-harmony.pdf. Frank Pfenning and Rowan Davies. A judgmental reconstruction of modal logic. Mathematical Structures in Computer Science, 11(4):511–540, 2001. Google Scholar
Digital Library
- Brigitte Pientka. A type-theoretic foundation for programming with higher-order abstract syntax and first-class substitutions. In Principles of Programming Languages, pages 371–382, 2008. Google Scholar
Digital Library
- Brigitte Pientka and Jana Dunfield. Beluga: A framework for programming and reasoning with deductive systems (system description). In Int?l Joint Conference on Automated Reasoning (IJCAR), pages 15?21, 2010. Google Scholar
Digital Library
- Benjamin C. Pierce and David N. Turner. Local type inference. In Principles of Programming Languages, pages 252–265, 1998. Google Scholar
Digital Library
- Full version in ACM Trans. Prog. Lang. Sys., 22(1):1–44, 2000.Google Scholar
Digital Library
- Dag Prawitz. Natural Deduction. Almqvist & Wiksells, 1965.Google Scholar
- Jeremy Siek and Walid Taha. Gradual typing for objects. In European Conference on Object-Oriented Programming, pages 2–27. Springer, 2007. Google Scholar
Digital Library
- Jeremy G. Siek and Walid Taha. Gradual typing for functional languages. In Proceedings of the Scheme and Functional Programming Workshop, pages 81–92, September 2006.Google Scholar
- Jeremy G. Siek and Manish Vachharajani. Gradual typing with unification-based inference. In Symposium on Dynamic Languages (DLS), pages 7:1–7:12, 2008. Google Scholar
Digital Library
- Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. Refined criteria for gradual typing. In LIPIcs-Leibniz International Proceedings in Informatics, volume 32. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2015.Google Scholar
- Philip Wadler and Robert Bruce Findler. Well-typed programs can’t be blamed. In European Symposium on Programming, pages 1– 16, 2009. Google Scholar
Digital Library
- Hongwei Xi and Frank Pfenning. Dependent types in practical programming. In Principles of Programming Languages, pages 214–227, 1999. Google Scholar
Digital Library
Index Terms
Sums of uncertainty: refinements go gradual
Recommendations
Sums of uncertainty: refinements go gradual
POPL '17: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming LanguagesA long-standing shortcoming of statically typed functional languages is that type checking does not rule out pattern-matching failures (run-time match exceptions). Refinement types distinguish different values of datatypes; if a program annotated with ...
Gradual refinement types
POPL '17Refinement types are an effective language-based verification technique. However, as any expressive typing discipline, its strength is its weakness, imposing sometimes undesired rigidity. Guided by abstract interpretation, we extend the gradual typing ...
Gradual refinement types
POPL '17: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming LanguagesRefinement types are an effective language-based verification technique. However, as any expressive typing discipline, its strength is its weakness, imposing sometimes undesired rigidity. Guided by abstract interpretation, we extend the gradual typing ...







Comments