skip to main content
research-article
Open Access
Artifacts Available

Gradual typing with union and intersection types

Published:29 August 2017Publication History
Skip Abstract Section

Abstract

We propose a type system for functional languages with gradual types and set-theoretic type connectives and prove its soundness. In particular, we show how to lift the definition of the domain and result type of an application from non-gradual types to gradual ones and likewise for the subtyping relation. We also show that deciding subtyping for gradual types can be reduced in linear time to deciding subtyping on non-gradual types and that the same holds true for all subtyping-related decision problems that must be solved for type inference. More generally, this work not only enriches gradual type systems with unions and intersections and with the type precision that arise from their use, but also proposes and advocates a new style of gradual types programming where union and intersection types are used by programmers to instruct the system to perform fewer dynamic checks.

Skip Supplemental Material Section

Supplemental Material

References

  1. Véronique Benzaken, Giuseppe Castagna, and Alain Frisch. 2003. CDuce: an XML-centric general-purpose language. In Proceedings of the 8th ACM SIGPLAN International Conference on Functional Programming (ICFP ’03). ACM, 51–63. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Giuseppe Castagna. 2015. Covariance and Contravariance: a fresh look at an old issue (a primer in advanced type systems for learning functional programmers). (2015). Unpublished manuscript, available at the author’s web page.Google ScholarGoogle Scholar
  3. Giuseppe Castagna, Giorgio Ghelli, and Giuseppe Longo. 1995. A calculus for overloaded functions with subtyping. Information and Computation 117, 1 (1995), 115–135. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Giuseppe Castagna, Kim Nguyen, Zhiwu Xu, and Pietro Abate. 2015. Polymorphic Functions with Set-Theoretic Types. Part 2: Local Type Inference and Type Reconstruction. In Proceedings of the 42nd ACM Symposium on Principles of Programming Languages (POPL ’15). ACM, 289–302. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Giuseppe Castagna, Kim Nguyen, Zhiwu Xu, Hyeonseung Im, Sergueï Lenglet, and Luca Padovani. 2014. Polymorphic Functions with Set-Theoretic Types. Part 1: Syntax, Semantics, and Evaluation. In Proceedings of the 41st ACM Symposium on Principles of Programming Languages (POPL ’14). ACM, 5–17. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Giuseppe Castagna, Tommaso Petrucciani, and Kim Nguyen. 2016. Set-Theoretic Types for Polymorphic Variants. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming (ICFP ’16). ACM, 378–391. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Avik Chaudhuri. 2014. Flow: A static type checker for JavaScript. Facebook. https://flowtype.org .Google ScholarGoogle Scholar
  8. Patrick Cousot and Radhia Cousot. 1977. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In Proceedings of the 4th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL ’77). ACM, 238–252. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Christos Dimoulas, Sam Tobin-Hochstadt, and Matthias Felleisen. 2012. Complete Monitors for Behavioral Contracts. In Programming Languages and Systems - 21st European Symposium on Programming, ESOP´’12. 214–233. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Alain Frisch. 2004. Regular Tree Language Recognition with Static Information. In IFIP 18th World Computer Congress TC1, 3rd International Conference on Theoretical Computer Science (TCS2004) (IFIP), Vol. 155. Kluwer/Springer, 661–674. Google ScholarGoogle ScholarCross RefCross Ref
  11. Alain Frisch, Giuseppe Castagna, and Véronique Benzaken. 2008. Semantic Subtyping: dealing set-theoretically with function, union, intersection, and negation types. J. ACM 55, 4 (2008), 1–64. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Ronald Garcia and Matteo Cimini. 2015. Principal Type Schemes for Gradual Programs. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’15). ACM, 303–315. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Ronald Garcia, Alison M Clark, and Éric Tanter. 2016. Abstracting gradual typing. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’16). ACM, 429–442. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Khurram A. Jafery and Joshua Dunfield. 2017. Sums of Uncertainty: Refinements Go Gradual. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL ’17). ACM, 804–817. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Nico Lehmann and Éric Tanter. 2017. Gradual refinement types. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL ’17). ACM, 18–20. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. John C. Reynolds. 1996. Design of the Programming Language Forsythe. Technical Report CMU-CS-96-146. Carnegie Mellon University.Google ScholarGoogle Scholar
  17. Jeremy G. Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Proceedings of Scheme and Functional Programming Workshop. ACM, 81–92.Google ScholarGoogle Scholar
  18. Jeremy G. Siek and Sam Tobin-Hochstadt. 2016. The Recursive Union of Some Gradual Types. In A List of Successes That Can Change the World: Essays Dedicated to Philip Wadler on the Occasion of His 60th Birthday, Sam Lindley, Conor McBride, Phil Trinder, and Don Sannella (Eds.). Springer, 388–410. Google ScholarGoogle ScholarCross RefCross Ref
  19. Jeremy G. Siek and Manish Vachharajani. 2008. Gradual typing with unification-based inference. In Proceedings of the 2008 Symposium on Dynamic languages. ACM, 7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Jeremy G. Siek, Michael M Vitousek, Matteo Cimini, and John Tang Boyland. 2015. Refined criteria for gradual typing. In LIPIcs-Leibniz International Proceedings in Informatics, Vol. 32. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik.Google ScholarGoogle Scholar
  21. Jeremy G. Siek and Philip Wadler. 2010. Threesomes, with and Without Blame. In Proceedings of the 37th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’10). ACM, 365–376. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Asumu Takikawa, Daniel Feltey, Ben Greenman, Max S. New, Jan Vitek, and Matthias Felleisen. 2016. Is Sound Gradual Typing Dead?. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’16). ACM, 456–468. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Sam Tobin-Hochstadt and Matthias Felleisen. 2008. The Design and Implementation of Typed Scheme. In Proceedings of the 35th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’08). ACM, 395–406. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Philip Wadler and Robert Bruce Findler. 2009. Well-Typed Programs Can’T Be Blamed. In Proceedings of the 18th European Symposium on Programming Languages and Systems (LNCS). Springer, 1–16. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Andrew K. Wright and Matthias Felleisen. 1994. A Syntactic Approach to Type Soundness. Information and Computation 115, 1 (1994), 38 – 94. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Gradual typing with union and intersection types

      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