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

Space-Efficient Polymorphic Gradual Typing, Mostly Parametric

Published: 20 June 2024 Publication History
  • Get Citation Alerts
  • Abstract

    Since the arrival of gradual typing, which allows partially typed code in a single program, efficient implementations of gradual typing have been an active research topic. In this paper, we study the space-efficiency problem of gradual typing in the presence of parametric polymorphism. Based on the existing work that showed the impossibility of a space-efficient implementation that supports fully parametric polymorphism, this paper will show that a space-efficient implementation is, in principle, possible by slightly relaxing parametricity. We first develop λCmp, which is a coercion calculus with mostly parametric polymorphism, and show its relaxed parametricity. Then, we present λSmp, a space-efficient version of λCmp, and prove that λSmp programs can be executed in a space-efficient manner and that translation from λCmp to λSmp is type- and semantics-preserving.

    Supplementary Material

    Auxiliary Archive (pldi24main-p478-p-archive.zip)
    This is a Supplementary Material for the PLDI'24 paper entitled “Space-Efficient Polymorphic Gradual Typing, Mostly Parametric”.

    References

    [1]
    Martín Abadi, Luca Cardelli, Benjamin C. Pierce, and Didier Rémy. 1995. Dynamic Typing in Polymorphic Languages. J. Funct. Program., 5, 1 (1995), 111–130. https://doi.org/10.1017/S095679680000126X
    [2]
    Amal Ahmed, Robert Bruce Findler, Jeremy G. Siek, and Philip Wadler. 2011. Blame for all. In Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2011, Austin, TX, USA, January 26-28, 2011, Thomas Ball and Mooly Sagiv (Eds.). ACM, 201–214. https://doi.org/10.1145/1926385.1926409
    [3]
    Amal Ahmed, Dustin Jamner, Jeremy G. Siek, and Philip Wadler. 2017. Theorems for free for free: parametricity, with and without types. PACMPL, 1, ICFP (2017), 39:1–39:28. https://doi.org/10.1145/3110283
    [4]
    Felipe Bañados Schwerter, Alison M. Clark, Khurram A. Jafery, and Ronald Garcia. 2021. Abstracting Gradual Typing Moving Forward: Precise and Space-Efficient. Proc. ACM Program. Lang., 5, POPL (2021), Article 61, Jan., 28 pages. https://doi.org/10.1145/3434342
    [5]
    Spenser Bauman, Carl Friedrich Bolz-Tereick, Jeremy G. Siek, and Sam Tobin-Hochstadt. 2017. Sound gradual typing: only mostly dead. PACMPL, 1, OOPSLA (2017), 54:1–54:24. https://doi.org/10.1145/3133878
    [6]
    Gavin M. Bierman, Martín Abadi, and Mads Torgersen. 2014. Understanding TypeScript. In ECOOP 2014 - Object-Oriented Programming - 28th European Conference, Uppsala, Sweden, July 28 - August 1, 2014. Proceedings, Richard E. Jones (Ed.) (Lecture Notes in Computer Science, Vol. 8586). Springer, 257–281. https://doi.org/10.1007/978-3-662-44202-9_11
    [7]
    Ambrose Bonnaire-Sergeant, Rowan Davies, and Sam Tobin-Hochstadt. 2016. Practical Optional Types for Clojure. In Programming Languages and Systems - 25th European Symposium on Programming, ESOP 2016, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2016, Eindhoven, The Netherlands, April 2-8, 2016, Proceedings, Peter Thiemann (Ed.) (Lecture Notes in Computer Science, Vol. 9632). Springer, 68–94. https://doi.org/10.1007/978-3-662-49498-1_4
    [8]
    Val Breazu-Tannen, Thierry Coquand, Carl A Gunter, and Andre Scedrov. 1991. Inheritance as implicit coercion. Information and Computation, 93, 1 (1991), July, 172–221. issn:0890-5401 https://doi.org/10.1016/0890-5401(91)90055-7
    [9]
    Julien Cretin and Didier Rémy. 2012. On the power of coercion abstraction. In Proceedings of the 39th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2012, Philadelphia, Pennsylvania, USA, January 22-28, 2012, John Field and Michael Hicks (Eds.). ACM, 361–372. https://doi.org/10.1145/2103656.2103699
    [10]
    Facebook. 2021. Hack. http://hacklang.org
    [11]
    Matthew Flatt and PLT. 2010. Reference: Racket. PLT Design Inc. https://racket-lang.org/tr1/
    [12]
    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 2016, St. Petersburg, FL, USA, January 20 - 22, 2016, Rastislav Bodík and Rupak Majumdar (Eds.). ACM, 429–442. isbn:978-1-4503-3549-2 https://doi.org/10.1145/2837614.2837670
    [13]
    Fritz Henglein. 1994. Dynamic Typing: Syntax and Proof Theory. Sci. Comput. Program., 22, 3 (1994), 197–230. https://doi.org/10.1016/0167-6423(94)00004-2
    [14]
    David Herman, Aaron Tomb, and Cormac Flanagan. 2007. Space-Efficient Gradual Typing. In Proceedings of the Eighth Symposium on Trends in Functional Programming, TFP 2007, New York City, New York, USA, April 2-4. 2007, Marco T. Morazán (Ed.) (Trends in Functional Programming, Vol. 8). Intellect, 1–18.
    [15]
    David Herman, Aaron Tomb, and Cormac Flanagan. 2010. Space-efficient gradual typing. Higher-Order and Symbolic Computation, 23, 2 (2010), 167–189. https://doi.org/10.1007/s10990-011-9066-z
    [16]
    Xuejing Huang and Bruno C. d. S. Oliveira. 2020. A Type-Directed Operational Semantics For a Calculus with a Merge Operator. In 34th European Conference on Object-Oriented Programming, ECOOP 2020, November 15-17, 2020, Berlin, Germany (Virtual Conference), Robert Hirschfeld and Tobias Pape (Eds.) (LIPIcs, Vol. 166). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 26:1–26:32. https://doi.org/10.4230/LIPICS.ECOOP.2020.26
    [17]
    Yuu Igarashi, Taro Sekiyama, and Atsushi Igarashi. 2017. On polymorphic gradual typing. PACMPL, 1, ICFP (2017), 40:1–40:29. https://doi.org/10.1145/3110284
    [18]
    Andre Kuhlenschmidt, Deyaaeldeen Almahallawi, and Jeremy G. Siek. 2019. Toward Efficient Gradual Typing for Structural Types via Coercions. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2019). Association for Computing Machinery, New York, NY, USA. 517–532. isbn:9781450367127 https://doi.org/10.1145/3314221.3314627
    [19]
    Zhaohui Luo. 1999. Coercive Subtyping. Journal of Logic and Computation, 9, 1 (1999), 105–130. issn:0955-792X
    [20]
    Jacob Matthews and Amal Ahmed. 2008. Parametric Polymorphism through Run-Time Sealing or, Theorems for Low, Low Prices!. In Proc. of European Symposium on Programming (ESOP’08). Springer Berlin Heidelberg, 16–31. https://doi.org/10.1007/978-3-540-78739-6_2
    [21]
    John C Mitchell. 1984. Coercion and type inference. In Proceedings of the 11th ACM SIGACT-SIGPLAN symposium on Principles of programming languages (POPL ’84). Association for Computing Machinery, New York, NY, USA. 175–185. isbn:9780897911252 https://doi.org/10.1145/800017.800529
    [22]
    John C. Mitchell. 1988. Polymorphic Type Inference and Containment. Inf. Comput., 76, 2/3 (1988), 211–249. https://doi.org/10.1016/0890-5401(88)90009-0
    [23]
    Yusuke Miyazaki, Taro Sekiyama, and Atsushi Igarashi. 2019. Dynamic Type Inference for Gradual Hindley–Milner Typing. PACM on Programming Languages, 3, POPL (2019), Jan., 18:1–18:29. https://doi.org/10.1145/3290331 Presented at ACM POPL 2019
    [24]
    James H Morris, Jr. 1973. Protection in programming languages. Commun. ACM, 16, 1 (1973), Jan., 15–21. issn:0001-0782 https://doi.org/10.1145/361932.361937
    [25]
    Fabian Muehlboeck and Ross Tate. 2017. Sound gradual typing is nominally alive and well. PACMPL, 1, OOPSLA (2017), 56:1–56:30. https://doi.org/10.1145/3133880
    [26]
    Max S. New, Dustin Jamner, and Amal Ahmed. 2020. Graduality and parametricity: together again for the first time. Proc. ACM Program. Lang., 4, POPL (2020), 46:1–46:32. https://doi.org/10.1145/3371114
    [27]
    Shota Ozaki, Taro Sekiyama, and Atsushi Igarashi. 2021. Is Space-Efficient Polymorphic Gradual Typing Possible? In Scheme and Functional Programming Workshop.
    [28]
    Benjamin Pierce and Eijiro Sumii. 2000. Relating Cryptography and Polymorphism. Manuscript. http://www.kb.ecei.tohoku.ac.jp/ sumii/pub/infohide.pdf
    [29]
    Aseem Rastogi, Nikhil Swamy, Cédric Fournet, Gavin M. Bierman, and Panagiotis Vekris. 2015. Safe & Efficient Gradual Typing for TypeScript. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, Mumbai, India, January 15-17, 2015. 167–180. https://doi.org/10.1145/2676726.2676971
    [30]
    Didier Rémy and Boris Yakobowski. 2010. A Church-Style Intermediate Language for MLF. In Functional and Logic Programming. Springer Berlin Heidelberg, 24–39. https://doi.org/10.1007/978-3-642-12251-4_4
    [31]
    John C. Reynolds. 1988. Preliminary Design of the Programming Language Forsythe. Carnegie Mellon University, Pittsburgh, PA. https://doi.org/10.1184/R1/6608582.v1
    [32]
    Gregor Richards, Ellen Arteca, and Alexi Turcotte. 2017. The VM already knew that: leveraging compile-time knowledge to optimize gradual typing. PACMPL, 1, OOPSLA (2017), 55:1–55:27. https://doi.org/10.1145/3133879
    [33]
    Davide Sangiorgi, Naoki Kobayashi, and Eijiro Sumii. 2007. Environmental Bisimulations for Higher-Order Languages. In 22nd IEEE Symposium on Logic in Computer Science (LICS 2007), 10-12 July 2007, Wroclaw, Poland, Proceedings. IEEE Computer Society, 293–302. https://doi.org/10.1109/LICS.2007.17
    [34]
    Jeremy G. Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In In Scheme and Functional Programming Workshop. 81–92.
    [35]
    Jeremy G. Siek and Walid Taha. 2007. Gradual Typing for Objects. In ECOOP 2007 - Object-Oriented Programming, 21st European Conference, Berlin, Germany, July 30 - August 3, 2007, Proceedings, Erik Ernst (Ed.) (Lecture Notes in Computer Science, Vol. 4609). Springer, 2–27. https://doi.org/10.1007/978-3-540-73589-2_2
    [36]
    Jeremy G. Siek, Peter Thiemann, and Philip Wadler. 2015. Blame and coercion: together again for the first time. In Proceedings of the 36th ACM SIGPLAN Conference on Progra Language Design and Implementation, Portland, OR, USA, June 2015, David Grove and Stephen M. Blackburn (Eds.). ACM, 425–435. https://doi.org/10.1145/2737924.2737968
    [37]
    Jeremy G. Siek, Peter Thiemann, and Philip Wadler. 2021. Blame and coercion: Together again for the first time. J. Funct. Program., 31 (2021), e20. https://doi.org/10.1017/S0956796821000101 A preliminary version is presented at ACM PLDI’15
    [38]
    Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. 2015. Refined Criteria for Gradual Typing. In 1st Summit on Advances in Programming Languages, SNAPL 2015, May 3-6, 2015, Asilomar, California, USA, Thomas Ball, Rastislav Bodík, Shriram Krishnamurthi, Benjamin S. Lerner, and Greg Morrisett (Eds.) (LIPIcs, Vol. 32). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 274–293. https://doi.org/10.4230/LIPIcs.SNAPL.2015.274
    [39]
    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. 45, ACM, 365–376. isbn:9781605584799 issn:0362-1340 https://doi.org/10.1145/1706299.1706342
    [40]
    Nikhil Swamy, Michael Hicks, and Gavin M Bierman. 2009. A Theory of Typed Coercions and Its Applications. In Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming (ICFP ’09). ACM, New York, NY, USA. 329–340. isbn:9781605583327 https://doi.org/10.1145/1596550.1596598
    [41]
    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 2016, St. Petersburg, FL, USA, January 20 - 22, 2016, Rastislav Bodík and Rupak Majumdar (Eds.). ACM, 456–468. https://doi.org/10.1145/2837614.2837630
    [42]
    Sam Tobin-Hochstadt and Matthias Felleisen. 2006. Interlanguage migration: from scripts to programs. In Proc. of Dynamic Languages Symposium. 964–974. https://doi.org/10.1145/1176617.1176755
    [43]
    Matías Toro, Elizabeth Labrada, and Éric Tanter. 2019. Gradual parametricity, revisited. Proc. ACM Program. Lang., 3, POPL (2019), 17:1–17:30. https://doi.org/10.1145/3290330
    [44]
    Yuya Tsuda, Atsushi Igarashi, and Tomoya Tabuchi. 2020. Space-Efficient Gradual Typing in Coercion-Passing Style. In 34th European Conference on Object-Oriented Programming (ECOOP2020), Robert Hirschfeld and Tobias Pape (Eds.) (LIPIcs, Vol. 166). Schloss Dagstuhl - Leibniz-Zentrum für Informatik. https://doi.org/10.4230/LIPIcs.ECOOP.2020.8
    [45]
    Philip Wadler. 1989. Theorems for free!. In Proceedings of the fourth international conference on Functional programming languages and computer architecture - FPCA ’89. ACM Press, New York, New York, USA. 347–359. isbn:9780897913287 https://doi.org/10.1145/99370.99404
    [46]
    Philip Wadler and Robert Bruce Findler. 2009. Well-Typed Programs Can’t Be Blamed. In Programming Languages and Systems, 18th European Symposium on Programming, ESOP 2009, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2009, York, UK, March 22-29, 2009. Proceedings. 1–16. https://doi.org/10.1007/978-3-642-00590-9_1
    [47]
    A K Wright and M Felleisen. 1994. A Syntactic Approach to Type Soundness. Information and Computation, 115, 1 (1994), Nov., 38–94. issn:0890-5401 https://doi.org/10.1006/inco.1994.1093
    [48]
    Ningning Xie, Xuan Bi, and Bruno C d S Oliveira. 2018. Consistent Subtyping for All. In Programming Languages and Systems. Springer International Publishing, 3–30. https://doi.org/10.1007/978-3-319-89884-1_1

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Proceedings of the ACM on Programming Languages
    Proceedings of the ACM on Programming Languages  Volume 8, Issue PLDI
    June 2024
    2198 pages
    EISSN:2475-1421
    DOI:10.1145/3554317
    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: 20 June 2024
    Published in PACMPL Volume 8, Issue PLDI

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Gradual typing
    2. Parametricity
    3. Space efficiency

    Qualifiers

    • Research-article

    Funding Sources

    • Japan Society for the Promotion of Science

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • 0
      Total Citations
    • 97
      Total Downloads
    • Downloads (Last 12 months)97
    • Downloads (Last 6 weeks)97

    Other Metrics

    Citations

    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