Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Gradual typing: a new perspective

Published: 02 January 2019 Publication History
  • Get Citation Alerts
  • Abstract

    We define a new, more semantic interpretation of gradual types and use it to ``gradualize'' two forms of polymorphism: subtyping polymorphism and implicit parametric polymorphism. In particular, we use the new interpretation to define three gradual type systems ---Hindley-Milner, with subtyping, and with union and intersection types--- in terms of two preorders, subtyping and materialization. We define these systems both declaratively ---by adding two subsumption-like rules--- which yields clearer, more intelligible, and streamlined definitions, and algorithmically by reusing existing techniques such as unification and tallying.

    Supplementary Material

    Auxiliary Archive (popl19main-p128-p-aux.zip)
    Appendix with all the proofs and some auxiliary definitions and results.
    WEBM File (a16-lanvin.webm)

    References

    [1]
    Amal Ahmed, Robert Bruce Findler, Jeremy G. Siek, and Philip Wadler. 2011. Blame for all. ACM SIGPLAN Notices 46, 1 (2011), 201–214.
    [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).
    [3]
    Alexander Aiken and Edward L. Wimmers. 1993. Type Inclusion Constraints and Type Inference. In Proceedings of the Conference on Functional Programming Languages and Computer Architecture (FPCA ’93). ACM, New York, NY, USA, 31–41.
    [4]
    Alexander Aiken, Edward L. Wimmers, and T. K. Lakshman. 1994. Soft typing with conditional types. In POPL ’94: Proceedings of the 21st ACM SIGPLAN-SIGACT symposium on Principles of programming languages. ACM Press, New York, NY, USA, 163–173.
    [5]
    Pedro Ángelo and Mário Florido. 2018. Gradual Intersection Types. In Workshop on Intersection Types and Related Systems.
    [6]
    Spenser Bauman, Carl Friedrich Bolz-Tereick, Jeremy Siek, and Sam Tobin-Hochstadt. 2017. Sound Gradual Typing: Only Mostly Dead. Proc. ACM Program. Lang. 1, OOPSLA, Article 54 (Oct. 2017), 24 pages.
    [7]
    Gavin Bierman, Martín Abadi, and Mads Torgersen. 2014. Understanding TypeScript. In ECOOP 2014 – Object-Oriented Programming, Richard Jones (Ed.). Lecture Notes in Computer Science, Vol. 8586. Springer Berlin Heidelberg, 257–281.
    [8]
    John Peter Campora, Sheng Chen, Martin Erwig, and Eric Walkingshaw. 2017. Migrating Gradual Types. Proc. ACM Program. Lang. 2, POPL (Dec. 2017), 15:1–15:29.
    [9]
    Robert Cartwright and Mike Fagan. 1991. Soft typing. In Conference on Programming Language Design and Implementation (PLDI). ACM Press, 278–292.
    [10]
    Giuseppe Castagna. 2005. Semantic subtyping: challenges, perspectives, and open problems. In ICTCS 2005, Italian Conference on Theoretical Computer Science (Lecture Notes in Computer Science). Springer, 1–20.
    [11]
    Giuseppe Castagna. 2018. Covariance and Contravariance: a fresh look at an old issue (a primer in advanced type systems for learning functional programmers). (2018). First version: 02/2013, last revision: 09/2018. Unpublished manuscript.
    [12]
    Giuseppe Castagna and Alain Frisch. 2005. A gentle introduction to semantic subtyping. In Proceedings of PPDP ’05, the 7th ACM SIGPLAN International Symposium on Principles and Practice of Declarative Programming, pages 198-208, ACM Press (full version) and ICALP ’05, 32nd International Colloquium on Automata, Languages and Programming, Lecture Notes in Computer Science n. 3580, pages 30-34, Springer (summary). Lisboa, Portugal. Joint ICALP-PPDP keynote talk.
    [13]
    Giuseppe Castagna and Victor Lanvin. 2017. Gradual Typing with Union and Intersection Types. Proc. ACM Program. Lang. 1, ICFP ’17, Article 41 (Sept. 2017).
    [14]
    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.
    [15]
    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 2016). ACM, New York, NY, USA, 378–391.
    [16]
    Giuseppe Castagna and Zhiwu Xu. 2011. Set-theoretic Foundation of Parametric Polymorphism and Subtyping. In ICFP ’11: 16th ACM-SIGPLAN International Conference on Functional Programming. 94–106.
    [17]
    Bruno Courcelle. 1983. Fundamental properties of infinite trees. Theoretical Computer Science 25 (1983), 95–169.
    [18]
    Stephen Dolan and Alan Mycroft. 2017. Polymorphism, Subtyping, and Type Inference in MLsub. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017). ACM, New York, NY, USA, 60–72.
    [19]
    Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for Higher-Order Functions. Technical Report NU-CCS-02-05. Northeastern University.
    [20]
    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.
    [21]
    You-Chin Fuh and Prateek Mishra. 1988. Type inference with subtypes. In ESOP ’88, H. Ganzinger (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 94–114.
    [22]
    Ronald Garcia. 2013. Calculating Threesomes, with Blame. In ICFP ’13: Proceedings of the International Conference on Functional Programming.
    [23]
    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.
    [24]
    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.
    [25]
    Nils Gesbert, Pierre Genevès, and Nabil Layaïda. 2015. A Logical Approach to Deciding Semantic Subtyping. ACM Trans. Program. Lang. Syst. 38, 1 (2015), 3.
    [26]
    Robert Harper. 2006. Programming Languages: Theory and Practice. Carnegie Mellon University. Available on the web: http://fpl.cs.depaul.edu/jriely/547/extras/online.pdf .
    [27]
    Fritz Henglein. 1994. Dynamic typing: syntax and proof theory. Science of Computer Programming 22, 3 (June 1994), 197–230.
    [28]
    Haruo Hosoya, Jérôme Vouillon, and Benjamin C. Pierce. 2000. Regular Expression Types for XML. In ICFP ’00 (SIGPLAN Notices), Vol. 35(9). http://www.cis.upenn.edu/~hahosoya/papers/regsub.ps
    [29]
    Yuu Igarashi, Taro Sekiyama, and Atsushi Igarashi. 2017. On Polymorphic Gradual Typing. In International Conference on Functional Programming (ICFP). ACM.
    [30]
    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).
    [31]
    Khurram A. Jafery and Joshua Dunfield. 2017. Sums of Uncertainty: Refinements go gradual. In Symposium on Principles of Programming Languages (POPL).
    [32]
    Matthias Keil and Peter Thiemann. 2015. Blame Assignment for Higher-order Contracts with Intersection and Union. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming (ICFP 2015). ACM, New York, NY, USA, 375–386.
    [33]
    Assaf J. Kfoury and Joe B. Wells. 2004. Principality and type inference for intersection types using expansion variables. Theoretical Computer Science 311, 1 (2004), 1 – 70.
    [34]
    Nicolás Lehmann and Éric Tanter. 2017. Gradual Refinement Types. In Symposium on Principles of Programming Languages (POPL).
    [35]
    André Murbach Maidl, Fabio Mascarenhas, and Roberto Ierusalimschy. 2014. Typed Lua: An Optional Type System for Lua. In Proceedings of the Workshop on Dynamic Languages and Applications (Dyla’14). ACM, New York, NY, USA, Article 3, 10 pages.
    [36]
    Alberto Martelli and Ugo Montanari. 1982. An Efficient Unification Algorithm. ACM Trans. Program. Lang. Syst. 4, 2 (1982), 258–282.
    [37]
    John C. Mitchell. 1991. Type inference with simple subtypes. Journal of Functional Programming 1, 3 (1991), 245–285.
    [38]
    Francisco Ortin and Miguel García. 2011. Union and intersection types to support both dynamic and static typing. Inform. Process. Lett. 111, 6 (2011), 278 – 286.
    [39]
    Tommaso Petrucciani, Giuseppe Castagna, Davide Ancona, and Elena Zucca. 2018. Semantic subtyping for non-strict languages. Technical Report. https://arxiv.org/abs/1810.05555 .
    [40]
    François Pottier. 2001. Simplifying subtyping constraints: a theory. Inf. Comput. 170, 2 (2001), 153–183.
    [41]
    François Pottier and Didier Rémy. 2005. The essence of ML type inference. In Advanced Topics in Types and Programming Languages, Benjamin C. Pierce (Ed.). MIT Press, Chapter 10, 389–489.
    [42]
    Aseem Rastogi, Avik Chaudhuri, and Basil Hosmer. 2012. The ins and outs of gradual type inference. In Symposium on Principles of Programming Languages (POPL). 481–494.
    [43]
    Simona Ronchi Della Rocca. 1988. Principal type scheme and unification for intersection type discipline. Theor. Comput. Sci. 59, 1-2 (1988), 181–209.
    [44]
    Taro Sekiyama, Atsushi Igarashi, and Michael Greenberg. 2017. Polymorphic Manifest Contracts, Revised and Resolved. ACM Trans. Program. Lang. Syst. 39, 1 (Feb. 2017), 3:1–3:36.
    [45]
    Jeremy G. Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Proceedings of Scheme and Functional Programming Workshop. ACM, 81–92.
    [46]
    Jeremy G. Siek and Walid Taha. 2007. Gradual Typing for Objects. In European Conference on Object-Oriented Programming (LCNS), Vol. 4609. 2–27.
    [47]
    Jeremy G. Siek, Peter Thiemann, and Philip Wadler. 2015a. Blame and coercion: together again for the first time. In ACM SIGPLAN Notices, Vol. 50. ACM, 425–435.
    [48]
    Jeremy G. Siek and Manish Vachharajani. 2008a. Gradual typing with unification-based inference. In Proceedings of the 2008 Symposium on Dynamic languages. ACM, 7.
    [49]
    Jeremy G. Siek and Manish Vachharajani. 2008b. Gradual Typing with Unification-based Inference. Technical Report CU-CS-1039-08. University of Colorado at Boulder.
    [50]
    Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. 2015b. Refined criteria for gradual typing. In LIPIcs-Leibniz International Proceedings in Informatics, Vol. 32. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik.
    [51]
    Nikhil Swamy, Cédric Fournet, Aseem Rastogi, Karthikeyan Bhargavan, Juan Chen, Pierre-Yves Strub, and Gavin Bierman. 2014. Gradual Typing Embedded Securely in JavaScript. In ACM Conference on Principles of Programming Languages (POPL).
    [52]
    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.
    [53]
    Matías Toro and Éric Tanter. 2017. A Gradual Interpretation of Union Types. In Proceedings of the 24th Static Analysis Symposium (SAS 2017) (Lecture Notes in Computer Science), Vol. 10422. Springer-Verlag, New York City, NY, USA, 382–404.
    [54]
    Philip Wadler and Robert Bruce Findler. 2009. Well-typed programs can’t be blamed. In European Symposium on Programming. Springer, 1–16.
    [55]
    Mitchell Wand. 1987. A simple algorithm and proof for type inference. Fundamenta Informaticae 10 (1987), 115–122.
    [56]
    Ningning Xie, Xuan Bi, and Bruno C. d. S. Oliveira. 2018. Consistent Subtyping for All. In Programming Languages and Systems, Amal Ahmed (Ed.). Springer International Publishing, Cham, 3–30.

    Cited By

    View all

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Proceedings of the ACM on Programming Languages
    Proceedings of the ACM on Programming Languages  Volume 3, Issue POPL
    January 2019
    2275 pages
    EISSN:2475-1421
    DOI:10.1145/3302515
    Issue’s Table of Contents
    This work is licensed under a Creative Commons Attribution International 4.0 License.

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 02 January 2019
    Published in PACMPL Volume 3, Issue POPL

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Gradual Typing
    2. Hindley-Milner
    3. Intersection Types
    4. Let-Polymorphism
    5. Semantic Subtyping
    6. Subtyping
    7. Union Types

    Qualifiers

    • Research-article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)286
    • Downloads (Last 6 weeks)35
    Reflects downloads up to 11 Aug 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Static Blame for gradual typingJournal of Functional Programming10.1017/S095679682400002934Online publication date: 25-Mar-2024
    • (2024)Gradual Typing Performance, Micro Configurations and Macro PerspectivesTheoretical Aspects of Software Engineering10.1007/978-3-031-64626-3_15(261-278)Online publication date: 29-Jul-2024
    • (2023)Gradual Typing for Effect HandlersProceedings of the ACM on Programming Languages10.1145/36228607:OOPSLA2(1758-1786)Online publication date: 16-Oct-2023
    • (2023)GTP Benchmarks for Gradual Typing PerformanceProceedings of the 2023 ACM Conference on Reproducibility and Replicability10.1145/3589806.3600034(102-114)Online publication date: 27-Jun-2023
    • (2023)A comparative study on DNA and protein binding properties of thymol and thymoquinoneJournal of Biomolecular Structure and Dynamics10.1080/07391102.2023.218066541:20(10944-10956)Online publication date: 25-Feb-2023
    • (2023)Programming with Union, Intersection, and Negation TypesThe French School of Programming10.1007/978-3-031-34518-0_12(309-378)Online publication date: 11-Oct-2023
    • (2022)Set-theoretic Types for ErlangProceedings of the 34th Symposium on Implementation and Application of Functional Languages10.1145/3587216.3587220(1-14)Online publication date: 31-Aug-2022
    • (2022)A Typed Lambda Calculus with Gradual Intersection TypesProceedings of the 24th International Symposium on Principles and Practice of Declarative Programming10.1145/3551357.3551382(1-13)Online publication date: 20-Sep-2022
    • (2022)On type-cases, union elimination, and occurrence typingProceedings of the ACM on Programming Languages10.1145/34986746:POPL(1-31)Online publication date: 12-Jan-2022
    • (2022)Gradualizing the Calculus of Inductive ConstructionsACM Transactions on Programming Languages and Systems10.1145/349552844:2(1-82)Online publication date: 6-Apr-2022
    • Show More Cited By

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Full Access

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media