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

Gradual Typing for Effect Handlers

Published: 16 October 2023 Publication History
  • Get Citation Alerts
  • Abstract

    We present a gradually typed language, GrEff, with effects and handlers that supports migration from unchecked to checked effect typing. This serves as a simple model of the integration of an effect typing discipline with an existing effectful typed language that does not track fine-grained effect information. Our language supports a simple module system to model the programming model of gradual migration from unchecked to checked effect typing in the style of Typed Racket.
    The surface language GrEff is given semantics by elaboration to a core language Core GrEff. We equip Core GrEff with an inequational theory for reasoning about the semantic error ordering and desired program equivalences for programming with effects and handlers. We derive an operational semantics for the language from the equations provable in the theory. We then show that the theory is sound by constructing an operational logical relations model to prove the graduality theorem. This extends prior work on embedding-projection pair models of gradual typing to handle effect typing and subtyping.

    References

    [1]
    Kenichi Asai. 2005. Logical relations for call-by-value delimited continuations. In Revised Selected Papers from the Sixth Symposium on Trends in Functional Programming, TFP 2005, Tallinn, Estonia, 23-24 September 2005, Marko C. J. D. van Eekelen (Ed.) (Trends in Functional Programming, Vol. 6). 63–78.
    [2]
    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. https://doi.org/10.1145/2692915.2628149
    [3]
    Patrick Bahr, Hans Bugge Grathwohl, and Rasmus Ejlers Møgelberg. 2017. The clocks are ticking: No more delays!. In 2017 32nd Annual ACM/IEEE Symposium on Logic in Computer Science (LICS). 1–12. https://doi.org/10.1109/LICS.2017.8005097
    [4]
    Lars Birkedal, Rasmus Ejlers Mogelberg, Jan Schwinghammer, and Kristian Stovring. 2011. First Steps in Synthetic Guarded Domain Theory: Step-Indexing in the Topos of Trees. In lics11. https://doi.org/10.1109/LICS.2011.16
    [5]
    Jonathan Immanuel Brachthäuser, Philipp Schuster, and Klaus Ostermann. 2020. Effekt: Capability-passing style for type- and effect-safe, extensible effect handlers in Scala. J. Funct. Program., 30 (2020), e8. https://doi.org/10.1017/S0956796820000027
    [6]
    Giuseppe Castagna, Victor Lanvin, Tommaso Petrucciani, and Jeremy G. Siek. 2019. Gradual Typing: A New Perspective. Proc. ACM Program. Lang., 3, POPL (2019), Article 16, jan, 32 pages. https://doi.org/10.1145/3290329
    [7]
    WasmFX Contributors. [n.d.]. WasmFX: Effect Handlers for WebAssembly. https://wasmfx.dev/ Accessed: 2020-11-10.
    [8]
    Ezra Cooper, Sam Lindley, Philip Wadler, and Jeremy Yallop. 2006. Links: Web Programming Without Tiers. In Formal Methods for Components and Objects, 5th International Symposium, FMCO 2006, Amsterdam, The Netherlands, November 7-10, 2006, Revised Lectures (Lecture Notes in Computer Science, Vol. 4709). 266–296. https://doi.org/10.1007/978-3-540-74792-5_12
    [9]
    Derek Dreyer, Amal Ahmed, and Lars Birkedal. 2009. Logical Step-Indexed Logical Relations. In 2009 24th Annual IEEE Symposium on Logic In Computer Science. 71–80. https://doi.org/10.1109/LICS.2009.34
    [10]
    Yannick Forster, Ohad Kammar, Sam Lindley, and Matija Pretnar. 2019. On the expressive power of user-defined effects: Effect handlers, monadic reflection, delimited control. J. Funct. Program., 29 (2019), e15. https://doi.org/10.1017/S0956796819000121
    [11]
    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 2015, Mumbai, India, January 15-17, 2015, Sriram K. Rajamani and David Walker (Eds.). ACM, 303–315. https://doi.org/10.1145/2676726.2676992
    [12]
    Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting Gradual Typing. In ACM Symposium on Principles of Programming Languages (POPL). https://doi.org/10.1145/2837614.2837670
    [13]
    David Herman, Aaron Tomb, and Cormac Flanagan. 2010. Space-Efficient Gradual Typing. Higher Order Symbol. Comput., 23, 2 (2010), jun, 167–189. issn:1388-3690 https://doi.org/10.1007/s10990-011-9066-z
    [14]
    Oleg Kiselyov, Amr Sabry, and Cameron Swords. 2013. Extensible effects: an alternative to monad transformers. In Proceedings of the 2013 ACM SIGPLAN Symposium on Haskell, Boston, MA, USA, September 23-24, 2013. ACM, 59–70. https://doi.org/10.1145/2503778.2503791
    [15]
    Nico Lehmann and Éric Tanter. 2017. Gradual Refinement Types. In ACM Symposium on Principles of Programming Languages (POPL). https://doi.org/10.1145/3009837.3009856
    [16]
    Daan Leijen. 2014. Koka: Programming with Row Polymorphic Effect Types. In Proceedings 5th Workshop on Mathematically Structured Functional Programming, MSFP@ETAPS 2014, Grenoble, France, 12 April 2014 (EPTCS, Vol. 153). 100–126. https://doi.org/10.4204/EPTCS.153.8
    [17]
    Sam Lindley, Conor McBride, and Craig McLaughlin. 2017. Do be do be do. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, France, January 18-20, 2017. ACM, 500–514. https://doi.org/10.1145/3009837.3009897
    [18]
    Stefan Malewski, Michael Greenberg, and Éric Tanter. 2021. Gradually structured data. Proc. ACM Program. Lang., 5, OOPSLA (2021), 1–29. https://doi.org/10.1145/3485503
    [19]
    Daniel Marino and Todd D. Millstein. 2009. A generic type-and-effect system. In Proceedings of TLDI’09: 2009 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, Savannah, GA, USA, January 24, 2009, Andrew Kennedy and Amal Ahmed (Eds.). ACM, 39–50. https://doi.org/10.1145/1481861.1481868
    [20]
    H. Nakano. 2000. A modality for recursion. In Proceedings Fifteenth Annual IEEE Symposium on Logic in Computer Science (Cat. No.99CB36332). 255–266. https://doi.org/10.1109/LICS.2000.855774
    [21]
    Max S. New and Amal Ahmed. 2018. Graduality from Embedding-Projection Pairs. In International Conference on Functional Programming (ICFP), St. Louis, Missouri. https://doi.org/10.1145/3236768
    [22]
    Max S. New, Eric Giovannini, and Daniel R. Licata. 2023. Gradual Typing for Effect Handlers (Extended Version). https://maxsnew.com/docs/greff-extended.pdf
    [23]
    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
    [24]
    Max S. New and Daniel R. Licata. 2018. Call-by-name Gradual Type Theory. In Formal Structures for Computation and Deduction, Oxford England. https://doi.org/10.4230/LIPIcs.FSCD.2018.24
    [25]
    Max S. New, Daniel R. Licata, and Amal Ahmed. 2019. Gradual Type Theory. In ACM Symposium on Principles of Programming Languages (POPL), Cascais, Portugal. https://doi.org/10.1145/3290328
    [26]
    Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2019. Typed Equivalence of Effect Handlers and Delimited Control. In 4th International Conference on Formal Structures for Computation and Deduction, FSCD 2019, June 24-30, 2019, Dortmund, Germany, Herman Geuvers (Ed.) (LIPIcs, Vol. 131). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 30:1–30:16. https://doi.org/10.4230/LIPIcs.FSCD.2019.30
    [27]
    Gordon D. Plotkin and Matija Pretnar. 2009. Handlers of Algebraic Effects. 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 (Lecture Notes in Computer Science, Vol. 5502). 80–94. https://doi.org/10.1007/978-3-642-00590-9_7
    [28]
    Taro Sekiyama, Soichiro Ueda, and Atsushi Igarashi. 2015. Shifting the Blame - A Blame Calculus with Delimited Control. In Programming Languages and Systems - 13th Asian Symposium, APLAS 2015, Pohang, South Korea, November 30 - December 2, 2015, Proceedings, Xinyu Feng and Sungwoo Park (Eds.) (Lecture Notes in Computer Science, Vol. 9458). Springer, 189–207. https://doi.org/10.1007/978-3-319-26529-2_11
    [29]
    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). https://doi.org/10.4230/LIPIcs.SNAPL.2015.274
    [30]
    Jeremy G. Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Scheme and Functional Programming Workshop (Scheme). 81–92.
    [31]
    Jeremy G. Siek and Walid Taha. 2007. Gradual Typing for Objects. In European Conference on Object-Oriented Programming (ECOOP). https://doi.org/10.1007/978-3-540-73589-2_2
    [32]
    Jeremy G. Siek and Manish Vachharajani. 2008. Gradual typing with unification-based inference. In Proceedings of the 2008 Symposium on Dynamic Languages, DLS 2008, July 8, 2008, Paphos, Cyprus, Johan Brichau (Ed.). ACM, 7. https://doi.org/10.1145/1408681.1408688
    [33]
    K. C. Sivaramakrishnan, Stephen Dolan, Leo White, Tom Kelly, Sadiq Jaffer, and Anil Madhavapeddy. 2021. Retrofitting effect handlers onto OCaml. In PLDI ’21: 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation, Virtual Event, Canada, June 20-25, 2021. ACM, 206–221. https://doi.org/10.1145/3453483.3454039
    [34]
    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). Association for Computing Machinery, New York, NY, USA. 456–468. isbn:9781450335492 https://doi.org/10.1145/2837614.2837630
    [35]
    Asumu Takikawa, T. Stephen Strickland, and Sam Tobin-Hochstadt. 2013. Constraining Delimited Control with Contracts. In Programming Languages and Systems - 22nd European Symposium on Programming, ESOP 2013, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2013, Rome, Italy, March 16-24, 2013. Proceedings, Matthias Felleisen and Philippa Gardner (Eds.) (Lecture Notes in Computer Science, Vol. 7792). Springer, 229–248. https://doi.org/10.1007/978-3-642-37036-6_14
    [36]
    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. https://doi.org/10.1145/1328438.1328486
    [37]
    Philip Wadler. 2021. GATE: Gradual Effect Types. In Leveraging Applications of Formal Methods, Verification and Validation - 10th International Symposium on Leveraging Applications of Formal Methods, ISoLA 2021, Rhodes, Greece, October 17-29, 2021, Proceedings, Tiziana Margaria and Bernhard Steffen (Eds.) (Lecture Notes in Computer Science, Vol. 13036). Springer, 335–345. https://doi.org/10.1007/978-3-030-89159-6_21
    [38]
    Philip Wadler and Robert Bruce Findler. 2009. Well-typed programs can’t be blamed. In European Symposium on Programming (ESOP). 1–16. https://doi.org/10.1007/978-3-642-00590-9_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 7, Issue OOPSLA2
    October 2023
    2250 pages
    EISSN:2475-1421
    DOI:10.1145/3554312
    Issue’s Table of Contents
    This work is licensed under a Creative Commons Attribution 4.0 International License.

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 16 October 2023
    Published in PACMPL Volume 7, Issue OOPSLA2

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. effect handlers
    2. gradual typing
    3. graduality
    4. logical relation
    5. operational semantics

    Qualifiers

    • Research-article

    Funding Sources

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • 0
      Total Citations
    • 168
      Total Downloads
    • Downloads (Last 12 months)168
    • Downloads (Last 6 weeks)14
    Reflects downloads up to 11 Aug 2024

    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