skip to main content

Gradual liquid type inference

Published:24 October 2018Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

a132-vazou.webm

References

  1. Yves Bertot and Pierre Castéran. 2004. Coq’Art: The Calculus of Inductive Constructions. Springer Verlag.Google ScholarGoogle Scholar
  2. John Peter Campora, Sheng Chen, Martin Erwig, and Eric Walkingshaw. 2018. Migrating Gradual Types. PACMPL (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Sheng Chen and Martin Erwig. 2018. Systematic identification and communication of type errors. JFP 28.Google ScholarGoogle Scholar
  4. Sheng Chen, Martin Erwig, and Eric Walkingshaw. 2014. Extending Type Inference to Variational Programs. In TOPLAS. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Bruno. Courcelle and Joost Engelfriet. 2012. Graph Structure and Monadic Second-Order Logic: A Language-Theoretic Approach (1st ed.). Cambridge University Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Tim Freeman and Frank Pfenning. 1991. Refinement Types for ML. In PLDI. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Ronald Garcia and Matteo Cimini. 2015. Principal Type Schemes for Gradual Programs. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting Gradual Typing. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Michael Greenberg, Benjamin C. Pierce, and Stephanie Weirich. 2010. Contracts Made Manifest. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Christian Haack and Joe Wells. 2003. Type Error Slicing in Implicitly-Typed Higher-Order Languages. In ESOP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. K.W. Knowles and C. Flanagan. 2010. Hybrid type checking. In TOPLAS. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Nico Lehmann and Éric Tanter. 2017. Gradual Refinement Types. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Benjamin Lerner, Matthew Flower, Dan Grossman, and Craig Chambers. 2007. Searching for Type-Error Messages. In PLDI. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Phuc C. Nguyen and David Van Horn. 2015. Relatively complete counterexamples for higher-order programs. In PLDI. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Phuc C. Nguyen, Sam Tobin-Hochstadt, and David Van Horn. 2014. Soft Contract Verification. In ICFP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Phuc C. Nguyen, Sam Tobin-Hochstadt, and David Van Horn. 2018. Soft Contract Verification for Higher-order Stateful Programs. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle Scholar
  18. Zvonimir Pavlinovic, Tim King, and Thomas Wies. 2014. Finding minimum type error sources. In OOPSLA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Aseem Rastogi, Avik Chaudhuri, and Basil Hosmer. 2012. The ins and outs of gradual type inference. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. P. Rondon, M. Kawaguchi, and R. Jhala. 2008. Liquid Types. In PLDI. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Eric Seidel, Ranjit Jhala, and Westley Weimer. 2016. Dynamic witnesses for static type errors (or, ill-typed programs usually go wrong). In ICFP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. Jeremy Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Scheme and Functional Programming Workshop.Google ScholarGoogle Scholar
  24. Jeremy G. Siek and Manish Vachharajani. 2008. Gradual Typing with Unification-based Inference. In Dynamic Languages Symposium. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. 2015. Refined Criteria for Gradual Typing. In SNAPL.Google ScholarGoogle Scholar
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. Frank Tip and T. B. Dinesh. 2001. A slicing-based approach for locating type error. In TOSEM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Sam Tobin-Hochstadt and Matthias Felleisen. 2006. Interlanguage migration: From scripts to programs. In DLS. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Sam Tobin-Hochstadt and David Van Horn. 2012. Higher-order Symbolic Execution via Contracts. In OOPSLA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Niki Vazou, Eric L. Seidel, and Ranjit Jhala. 2014a. LiquidHaskell: Experience with Refinement Types in the Real World. In Haskell. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Niki Vazou, Eric L. Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon Peyton-Jones. 2014b. Refinement Types for Haskell. In ICFP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Niki Vazou, Éric Tanter, and David Van Horn. 2018a. Gradual Liquid Types. ArXiv e-prints (2018). arXiv: 1807.02132Google ScholarGoogle Scholar
  33. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  34. Mitchell Wand. 1986. Finding the Source of Type Errors. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Makarius Wenzel. 2016. The Isabelle System Manual. (2016). https://www.cl.cam.ac.uk/research/hvg/Isabelle/dist/ Isabelle2016- 1/doc/system.pdfGoogle ScholarGoogle Scholar
  36. Danfeng Zhang, Andrew C. Myers, Dimitrios Vytiniotis, and Simon Peyton-Jones. 2015. Diagnosing Type Errors with Class. In PLDI. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Gradual liquid type inference

    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

    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!