Abstract
Refinement types allow for lightweight program verification by enriching types with logical predicates. Liquid typing provides a decidable refinement inference mechanism that is convenient but subject to two major issues: (1) inference is global and requires top-level annotations, making it unsuitable for inference of modular code components and prohibiting its applicability to library code, and (2) inference failure results in obscure error messages. These difficulties seriously hamper the migration of existing code to use refinements.
This paper shows that gradual liquid type inference–a novel combination of liquid inference and gradual refinement types–addresses both issues. Gradual refinement types, which support imprecise predicates that are optimistically interpreted, can be used in argument positions to constrain liquid inference so that the global inference process effectively infers modular specifications usable for library components. Dually, when gradual refinements appear as the result of inference, they signal an inconsistency in the use of static refinements. Because liquid refinements are drawn from a finite set of predicates, in gradual liquid type inference we can enumerate the textitsafe concretizations of each imprecise refinement, i.e., the static refinements that justify why a program is gradually well-typed. This enumeration is useful for static liquid type error explanation, since the safe concretizations exhibit all the potential inconsistencies that lead to static type errors.
We develop the theory of gradual liquid type inference and explore its pragmatics in the setting of Liquid Haskell. To demonstrate the utility of our approach, we develop an interactive tool, GuiLT, for gradual liquid type inference in Liquid Haskell that both infers modular types and explores safe concretizations of gradual refinements. We report on the use of GuiLT for error reporting and discuss a case study on the migration of three commonly-used Haskell list manipulation libraries into Liquid Haskell.
Supplemental Material
- Yves Bertot and Pierre Castéran. 2004. Coq’Art: The Calculus of Inductive Constructions. Springer Verlag.Google Scholar
- John Peter Campora, Sheng Chen, Martin Erwig, and Eric Walkingshaw. 2018. Migrating Gradual Types. PACMPL (POPL). Google Scholar
Digital Library
- Sheng Chen and Martin Erwig. 2018. Systematic identification and communication of type errors. JFP 28.Google Scholar
- Sheng Chen, Martin Erwig, and Eric Walkingshaw. 2014. Extending Type Inference to Variational Programs. In TOPLAS. Google Scholar
Digital Library
- Bruno. Courcelle and Joost Engelfriet. 2012. Graph Structure and Monadic Second-Order Logic: A Language-Theoretic Approach (1st ed.). Cambridge University Press. Google Scholar
Digital Library
- Tim Freeman and Frank Pfenning. 1991. Refinement Types for ML. In PLDI. Google Scholar
Digital Library
- Ronald Garcia and Matteo Cimini. 2015. Principal Type Schemes for Gradual Programs. In POPL. Google Scholar
Digital Library
- Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting Gradual Typing. In POPL. Google Scholar
Digital Library
- Michael Greenberg, Benjamin C. Pierce, and Stephanie Weirich. 2010. Contracts Made Manifest. In POPL. Google Scholar
Digital Library
- Christian Haack and Joe Wells. 2003. Type Error Slicing in Implicitly-Typed Higher-Order Languages. In ESOP. Google Scholar
Digital Library
- K.W. Knowles and C. Flanagan. 2010. Hybrid type checking. In TOPLAS. Google Scholar
Digital Library
- Nico Lehmann and Éric Tanter. 2017. Gradual Refinement Types. In POPL. Google Scholar
Digital Library
- Benjamin Lerner, Matthew Flower, Dan Grossman, and Craig Chambers. 2007. Searching for Type-Error Messages. In PLDI. Google Scholar
Digital Library
- Phuc C. Nguyen and David Van Horn. 2015. Relatively complete counterexamples for higher-order programs. In PLDI. Google Scholar
Digital Library
- Phuc C. Nguyen, Sam Tobin-Hochstadt, and David Van Horn. 2014. Soft Contract Verification. In ICFP. Google Scholar
Digital Library
- Phuc C. Nguyen, Sam Tobin-Hochstadt, and David Van Horn. 2018. Soft Contract Verification for Higher-order Stateful Programs. In POPL. Google Scholar
Digital Library
- Xinming Ou, Gang Tan, Yitzhak Mandelbaum, and David Walker. 2004. Dynamic Typing with Dependent Types, Jean-Jacques Levy, Ernst W. Mayr, and John C. Mitchell (Eds.). IFIP.Google Scholar
- Zvonimir Pavlinovic, Tim King, and Thomas Wies. 2014. Finding minimum type error sources. In OOPSLA. Google Scholar
Digital Library
- Aseem Rastogi, Avik Chaudhuri, and Basil Hosmer. 2012. The ins and outs of gradual type inference. In POPL. Google Scholar
Digital Library
- P. Rondon, M. Kawaguchi, and R. Jhala. 2008. Liquid Types. In PLDI. Google Scholar
Digital Library
- Eric Seidel, Ranjit Jhala, and Westley Weimer. 2016. Dynamic witnesses for static type errors (or, ill-typed programs usually go wrong). In ICFP. Google Scholar
Digital Library
- Eric L. Seidel, Huma Sibghat, Kamalika Chaudhuri, Westley Weimer, and Ranjit Jhala. 2017. Learning to blame: localizing novice type errors with data-driven diagnosis. OOPSLA (2017). Google Scholar
Digital Library
- Jeremy Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Scheme and Functional Programming Workshop.Google Scholar
- Jeremy G. Siek and Manish Vachharajani. 2008. Gradual Typing with Unification-based Inference. In Dynamic Languages Symposium. Google Scholar
Digital Library
- Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. 2015. Refined Criteria for Gradual Typing. In SNAPL.Google Scholar
- N. Swamy, C. Hriţcu, C. Keller, A. Rastogi, A. Delignat-Lavaud, S. Forest, K. Bhargavan, C. Fournet, P. Y. Strub, M. Kohlweiss, J. K. Zinzindohoue, and S. Zanella-Béguelin. 2016. Dependent Types and Multi-Monadic Effects in F*. In POPL. Google Scholar
Digital Library
- Frank Tip and T. B. Dinesh. 2001. A slicing-based approach for locating type error. In TOSEM. Google Scholar
Digital Library
- Sam Tobin-Hochstadt and Matthias Felleisen. 2006. Interlanguage migration: From scripts to programs. In DLS. Google Scholar
Digital Library
- Sam Tobin-Hochstadt and David Van Horn. 2012. Higher-order Symbolic Execution via Contracts. In OOPSLA. Google Scholar
Digital Library
- Niki Vazou, Eric L. Seidel, and Ranjit Jhala. 2014a. LiquidHaskell: Experience with Refinement Types in the Real World. In Haskell. Google Scholar
Digital Library
- Niki Vazou, Eric L. Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon Peyton-Jones. 2014b. Refinement Types for Haskell. In ICFP. Google Scholar
Digital Library
- Niki Vazou, Éric Tanter, and David Van Horn. 2018a. Gradual Liquid Types. ArXiv e-prints (2018). arXiv: 1807.02132Google Scholar
- Niki Vazou, Anish Tondwalkar, Vikraman Choudhury, Ryan Scott, Ryan Newton, Philip Wadler, and Ranjit Jhala. 2018b. Refinement Reflection: Complete Verification with SMT. In POPL. Google Scholar
Digital Library
- Mitchell Wand. 1986. Finding the Source of Type Errors. In POPL. Google Scholar
Digital Library
- Makarius Wenzel. 2016. The Isabelle System Manual. (2016). https://www.cl.cam.ac.uk/research/hvg/Isabelle/dist/ Isabelle2016- 1/doc/system.pdfGoogle Scholar
- Danfeng Zhang, Andrew C. Myers, Dimitrios Vytiniotis, and Simon Peyton-Jones. 2015. Diagnosing Type Errors with Class. In PLDI. Google Scholar
Digital Library
Index Terms
Gradual liquid type inference
Recommendations
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 ...
Sums of uncertainty: refinements go gradual
POPL '17A 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 ...
Principal Type Schemes for Gradual Programs
POPL '15: Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesGradual typing is a discipline for integrating dynamic checking into a static type system. Since its introduction in functional languages, it has been adapted to a variety of type systems, including object-oriented, security, and substructural. This ...






Comments