skip to main content
research-article
Open Access

Graduality from embedding-projection pairs

Published:30 July 2018Publication History
Skip Abstract Section

Abstract

Gradually typed languages allow statically typed and dynamically typed code to interact while maintaining benefits of both styles. The key to reasoning about these mixed programs is Siek-Vitousek-Cimini-Boyland’s (dynamic) gradual guarantee, which says that giving components of a program more precise types only adds runtime type checking, and does not otherwise change behavior. In this paper, we give a semantic reformulation of the gradual guarantee called graduality. We change the name to promote the analogy that graduality is to gradual typing what parametricity is to polymorphism. Each gives a local-to-global, syntactic-to-semantic reasoning principle that is formulated in terms of a kind of observational approximation.

Utilizing the analogy, we develop a novel logical relation for proving graduality. We show that embedding-projection pairs (ep pairs) are to graduality what relations are to parametricity. We argue that casts between two types where one is “more dynamic” (less precise) than the other necessarily form an ep pair, and we use this to cleanly prove the graduality cases for casts from the ep-pair property. To construct ep pairs, we give an analysis of the type dynamism relation—also known as type precision or naïve subtyping—that interprets the rules for type dynamism as compositional constructions on ep pairs, analogous to the coercion interpretation of subtyping.

Skip Supplemental Material Section

Supplemental Material

a73-new.webm

webm

117.4 MB

References

  1. Amal Ahmed. 2006. Step-Indexed Syntactic Logical Relations for Recursive and Quantified Types. In European Symposium on Programming (ESOP). 69–83. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Amal Ahmed, Dustin Jamner, Jeremy G. Siek, and Philip Wadler. 2017. Theorems for Free for Free: Parametricity, With and Without Types. In International Conference on Functional Programming (ICFP), Oxford, United Kingdom.Google ScholarGoogle Scholar
  3. Esteban Allende, Oscar Callaú, Johan Fabry, Éric Tanter, and Marcus Denker. 2013. Gradual Typing for Smalltalk. Science of Computer Programming (Aug. 2013). Available online. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Felipe Bañados Schwerter, Ronald Garcia, and Éric Tanter. 2014. A Theory of Gradual Effect Systems. In Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming (ICFP ’14). 283–295. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Nick Benton. 2005. Embedded Interpreters. Journal of Functional Programming 15, 04 (2005), 503–542. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. John Tang Boyland. 2014. The Problem of Structural Type Tests in a Gradual-Typed Language. In Workshop on Foundations of Object-Oriented Languages (FOOL), informal proceedings.Google ScholarGoogle Scholar
  7. Matteo Cimini and Jeremy G. Siek. 2016. The Gradualizer: A Methodology and Algorithm for Generating Gradual Type Systems. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’16). Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Matteo Cimini and Jeremy G. Siek. 2017. Automatically Generating the Dynamic Semantics of Gradually Typed Languages. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017). 789–803. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Pierre-Evariste Dagand, Nicolas Tabareau, and Éric Tanter. 2016. Partial Type Equivalences for Verified Dependent Interoperability (ICFP 2016). 298–310. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Pierr-Évariste Dagand, Nicolas Tabareau, and Éric Tanter. 2018. Foundations of dependent interoperability. Journal of Functional Programming 28 (2018), e9.Google ScholarGoogle ScholarCross RefCross Ref
  11. Keun-Bang Hou (Favonia), Nick Benton, and Robert Harper. 2017. Correctness of compiling polymorphism to dynamic typing. Journal of Functional Programming 27 (2017).Google ScholarGoogle Scholar
  12. Matthias Felleisen and Robert Hieb. 1992. A Revised Report on the Syntactic Theories of Sequential Control and State. Theor. Comput. Sci. 103, 2 (1992), 235–271. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Robby Findler and Matthias Blume. 2006. Contracts as Pairs of Projections. In International Symposium on Functional and Logic Programming (FLOPS). Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for higher-order functions. In International Conference on Functional Programming (ICFP), Pittsburgh, Pennsylvania. 48–59. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Ronald Garcia, Alison M. Clark, and Eric Tanter. 2016a. Abstracting Gradual Typing. In ACM Symposium on Principles of Programming Languages (POPL), St. Petersburg, Florida. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016b. Abstracting Gradual Typing. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’16). Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Jessica Gronski, Kenneth Knowles, Aaron Tomb, Stephen N. Freund, and Cormac Flanagan. 2006. Sage: Hybrid Checking for Flexible Specifications. In Scheme and Functional Programming Workshop (Scheme). 93–104.Google ScholarGoogle Scholar
  18. Fritz Henglein. 1994. Dynamic Typing: Syntax and Proof Theory. Science of Computer Programming 22, 3 (1994), 197–230. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. David Herman, Aaron Tomb, and Cormac Flanagan. 2010. Space-efficient Gradual Typing. Higher Order Symbol. Comput. 23, 2 (June 2010). Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Atsushi Igarashi, Peter Thiemann, Vasco Vasconcelos, and Philip Wadler. 2017b. Gradual Session Types. In International Conference on Functional Programming (ICFP), Oxford, United Kingdom.Google ScholarGoogle Scholar
  21. Yuu Igarashi, Taro Sekiyama, and Atsushi Igarashi. 2017a. On Polymorphic Gradual Typing. In International Conference on Functional Programming (ICFP), Oxford, United Kingdom.Google ScholarGoogle Scholar
  22. Lintaro Ina and Atsushi Igarashi. 2011. Gradual typing for generics. In Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applications (OOPSLA ’11). Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Nico Lehmann and Éric Tanter. 2017. Gradual Refinement Types. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017). 775–788. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Max S. New and Amal Ahmed. 2018. Graduality from Embedding-Projection Pairs (Extended Version). ArXiv e-prints (July 2018). arXiv: 1807.02786Google ScholarGoogle Scholar
  25. Max S. New and Daniel R. Licata. 2018. Call-by-Name Gradual Type Theory. In 3rd International Conference on Formal Structures for Computation and Deduction (FSCD 2018) (Leibniz International Proceedings in Informatics (LIPIcs)), Hélène Kirchner (Ed.), Vol. 108. http://drops.dagstuhl.de/opus/volltexte/2018/9194Google ScholarGoogle Scholar
  26. Dana Scott. 1972. Continuous lattices. In Toposes, algebraic geometry and logic. 97–136.Google ScholarGoogle Scholar
  27. Jeremy Siek, Micahel Vitousek, Matteo Cimini, and John Tang Boyland. 2015. Refined Criteria for Gradual Typing. In 1st Summit on Advances in Programming Languages (SNAPL 2015).Google ScholarGoogle Scholar
  28. Jeremy G. Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Scheme and Functional Programming Workshop (Scheme). 81–92.Google ScholarGoogle Scholar
  29. Jeremy G. Siek and Philip Wadler. 2010. Threesomes, with and without blame. In ACM Symposium on Principles of Programming Languages (POPL), Madrid, Spain. 365–376. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Nikhil Swamy, Cédric Fournet, Aseem Rastogi, Karthikeyan Bhargavan, Juan Chen, Pierre-Yves Strub, and Gavin M. Bierman. 2014. Gradual typing embedded securely in JavaScript. In ACM Symposium on Principles of Programming Languages (POPL), San Diego, California. 425–438. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Satish Thatte. 1990. Quasi-static typing. In ACM Symposium on Principles of Programming Languages (POPL). 367–381. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Sam Tobin-Hochstadt and Matthias Felleisen. 2006. Interlanguage Migration: From Scripts to Programs. In Dynamic Languages Symposium (DLS). 964–974.Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Sam Tobin-Hochstadt and Matthias Felleisen. 2008. The Design and Implementation of Typed Scheme. In ACM Symposium on Principles of Programming Languages (POPL), San Francisco, California. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Philip Wadler and Robert Bruce Findler. 2009. Well-typed programs can’t be blamed. In European Symposium on Programming (ESOP). 1–16. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Roger Wolff, Ronald Garcia, Éric Tanter, and Jonathan Aldrich. 2011. Gradual Typestate. In Proceedings of the 25th European Conference on Object-oriented Programming (ECOOP’11). Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Graduality from embedding-projection pairs

        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