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

Effects as capabilities: effect handlers and lightweight effect polymorphism

Published: 13 November 2020 Publication History
  • Get Citation Alerts
  • Abstract

    Effect handlers have recently gained popularity amongst programming language researchers. Existing type- and effect systems for effect handlers are often complicated and potentially hinder a wide-spread adoption.
    We present the language Effekt with the goal to close the gap between research languages with effect handlers and languages for working programmers. The design of Effekt revolves around a different view of effects and effect types. Traditionally, effect types express which side effects a computation might have. In Effekt, effect types express which capabilities a computation requires from its context. While this new point in the design space of effect systems impedes reasoning about purity, we demonstrate that it simplifies the treatment of effect polymorphism and the related issues of effect parametricity and effect encapsulation. To guarantee effect safety, we separate functions from values and treat all functions as second-class. We define the semantics of Effekt as a translation to System Xi, a calculus in explicit capability-passing style.

    Supplementary Material

    Auxiliary Presentation Video (oopsla20main-p6-p-video.mp4)
    Jonathan Brachthäuser presents the OOPSLA 20 paper "Effects as Capabilities: Effect Handlers and Lightweight Effect Polymorphism".

    References

    [1]
    Henk P. Barendregt. 1992. Lambda Calculi with Types. In Handbook of Logic in Computer Science (vol. 2 ): Background: Computational Structures. Oxford University Press, New York, NY, USA, 117-309.
    [2]
    Andrej Bauer and Matija Pretnar. 2013. An efect system for algebraic efects and handlers. In International Conference on Algebra and Coalgebra in Computer Science. Springer, Berlin, Heidelberg, 1-16.
    [3]
    Andrej Bauer and Matija Pretnar. 2015. Programming with algebraic efects and handlers. Journal of Logical and Algebraic Methods in Programming 84, 1 ( 2015 ), 108-123.
    [4]
    Nick Benton, Chung-Kil Hur, Andrew J Kennedy, and Conor McBride. 2012. Strongly typed term representations in Coq. Journal of automated reasoning 49, 2 ( 2012 ), 141-159.
    [5]
    Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2017. Handle with Care: Relational Interpretation of Algebraic Efects and Handlers. Proc. ACM Program. Lang. 2, POPL, Article 8 ( Dec. 2017 ), 30 pages.
    [6]
    Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2019. Abstracting Algebraic Efects. Proc. ACM Program. Lang. 3, POPL, Article 6 ( Jan. 2019 ), 28 pages.
    [7]
    Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2020. Binders by Day, Labels by Night: Efect Instances via Lexically Scoped Handlers. In Proceedings of the Symposium on Principles of Programming Languages (to appear). ACM, New York, NY, USA.
    [8]
    Eli Bingham, Jonathan P. Chen, Martin Jankowiak, Fritz Obermeyer, Neeraj Pradhan, Theofanis Karaletsos, Rohit Singh, Paul Szerlip, Paul Horsfall, and Noah D. Goodman. 2019. Pyro: Deep Universal Probabilistic Programming. J. Mach. Learn. Res. 20, 1 (Jan. 2019 ), 973-978.
    [9]
    Jonathan Immanuel Brachthäuser and Philipp Schuster. 2017. Efekt: Extensible Algebraic Efects in Scala (Short Paper). In Proceedings of the International Symposium on Scala (Vancouver, BC, Canada). ACM, New York, NY, USA. https: //doi.org/10.1145/3136000.3136007
    [10]
    Jonathan Immanuel Brachthäuser, Philipp Schuster, and Klaus Ostermann. 2018. Efect Handlers for the Masses. Proc. ACM Program. Lang. 2, OOPSLA, Article 111 (Oct. 2018 ), 27 pages. https://doi.org/10.1145/3276481
    [11]
    Jonathan Immanuel Brachthäuser, Philipp Schuster, and Klaus Ostermann. 2020a. Efekt: Capability-Passing Style for Typeand Efect-safe, Extensible Efect Handlers in Scala. Journal of Functional Programming ( 2020 ). https://doi.org/10.1017/ S0956796820000027
    [12]
    Jonathan Immanuel Brachthäuser, Philipp Schuster, and Klaus Ostermann. 2020b. Efekt: Lightweight Efect Polymorphism for Handlers. Extended Technical Report. University of Tübingen, Germany. http://ps.informatik.uni-tuebingen.de/ publications/brachthaeuser20efekt.pdf.
    [13]
    Jonathan Immanuel Brachthäuser and Daan Leijen. 2019. Programming with Implicit Values, Functions, and Control. Technical Report MSR-TR-2019-7. Microsoft Research.
    [14]
    Edwin Brady. 2013. Idris, a general-purpose dependently typed programming language: Design and implementation. Journal of Functional Programming 23, 5 ( 2013 ), 552-593.
    [15]
    Lukas Convent, Sam Lindley, Conor McBride, and Craig McLaughlin. 2020. Doo Bee Doo Bee Doo. Journal of Functional Programming 30 ( 2020 ), e9. https://doi.org/10.1017/S0956796820000039
    [16]
    Olivier Danvy and Andrzej Filinski. 1989. A functional abstraction of typed contexts. DIKU Rapport 89 /12, DIKU, University of Copenhagen ( 1989 ).
    [17]
    Stephen Dolan, Spiros Eliopoulos, Daniel Hillerström, Anil Madhavapeddy, KC Sivaramakrishnan, and Leo White. 2017. Concurrent system programming with efect handlers. In Proceedings of the Symposium on Trends in Functional Programming. Springer LNCS 10788.
    [18]
    Stephen Dolan, Leo White, and Anil Madhavapeddy. 2014. Multicore OCaml. In OCaml Workshop.
    [19]
    Stephen Dolan, Leo White, KC Sivaramakrishnan, Jeremy Yallop, and Anil Madhavapeddy. 2015. Efective concurrency through algebraic efects. In OCaml Workshop.
    [20]
    R. Kent Dybvig, Simon L. Peyton Jones, and Amr Sabry. 2007. A monadic framework for delimited continuations. Journal of Functional Programming 17, 6 ( 2007 ), 687-730.
    [21]
    Richard A. Eisenberg, Joachim Breitner, and Simon Peyton Jones. 2018. Type Variables in Patterns. In Proceedings of the Haskell Symposium (St. Louis, MO, USA) ( Haskell 2018 ). Association for Computing Machinery, New York, NY, USA, 94-105. https://doi.org/10.1145/3242744.3242753
    [22]
    Matthias Felleisen. 1988. The Theory and Practice of First-class Prompts. In Proceedings of the Symposium on Principles of Programming Languages (San Diego, California, USA). ACM, New York, NY, USA, 180-190.
    [23]
    Carl A. Gunter, Didier Rémy, and Jon G. Riecke. 1995. A Generalization of Exceptions and Control in ML-like Languages. In Proceedings of the Conference on Functional Programming Languages and Computer Architecture (La Jolla, California, USA). ACM, New York, NY, USA, 12-23.
    [24]
    Daniel Hillerström and Sam Lindley. 2016. Liberating Efects with Rows and Handlers. In Proceedings of the Workshop on Type-Driven Development (Nara, Japan). ACM, New York, NY, USA.
    [25]
    Daniel Hillerström, Sam Lindley, Bob Atkey, and KC Sivaramakrishnan. 2017. Continuation Passing Style for Efect Handlers. In Formal Structures for Computation and Deduction (LIPIcs, Vol. 84 ). Schloss Dagstuhl-Leibniz-Zentrum für Informatik.
    [26]
    Ohad Kammar, Sam Lindley, and Nicolas Oury. 2013. Handlers in Action. In Proceedings of the International Conference on Functional Programming (Boston, Massachusetts, USA). ACM, New York, NY, USA, 145-158.
    [27]
    Oleg Kiselyov, Chung-chieh Shan, and Amr Sabry. 2006. Delimited Dynamic Binding. In Proceedings of the International Conference on Functional Programming (Portland, Oregon, USA). ACM, New York, NY, USA, 26-37.
    [28]
    Daan Leijen. 2005. Extensible records with scoped labels. In Proceedings of the Symposium on Trends in Functional Programming. 297-312.
    [29]
    Daan Leijen. 2014. Koka: Programming with Row Polymorphic Efect Types. In Proceedings of the Workshop on Mathematically Structured Functional Programming.
    [30]
    Daan Leijen. 2016. Algebraic Efects for Functional Programming. Technical Report. MSR-TR-2016-29. Microsoft Research technical report.
    [31]
    Daan Leijen. 2017a. Structured Asynchrony with Algebraic Efects. In Proceedings of the Workshop on Type-Driven Development (Oxford, UK). ACM, New York, NY, USA, 16-29.
    [32]
    Daan Leijen. 2017b. Type directed compilation of row-typed algebraic efects. In Proceedings of the Symposium on Principles of Programming Languages. ACM, New York, NY, USA, 486-499.
    [33]
    Daan Leijen. 2018a. Algebraic Efect Handlers with Resources and Deep Finalization. Technical Report MSR-TR-2018-10. Microsoft Research. 35 pages.
    [34]
    Daan Leijen. 2018b. First Class Dynamic Efect Handlers: Or, Polymorphic Heaps with Dynamic Efect Handlers. In Proceedings of the Workshop on Type-Driven Development (St. Louis, Missouri, USA). ACM, New York, NY, USA, 51-64.
    [35]
    Paul Blain Levy, John Power, and Hayo Thielecke. 2003. Modelling environments in call-by-value programming languages. Information and Computation 185, 2 ( 2003 ), 182-210.
    [36]
    Sam Lindley, Conor McBride, and Craig McLaughlin. 2017. Do Be Do Be Do. In Proceedings of the Symposium on Principles of Programming Languages (Paris, France). ACM, New York, NY, USA, 500-514.
    [37]
    Jirka Maršík and Maxime Amblard. 2016. Introducing a Calculus of Efects and Handlers for Natural Language Semantics. In International Conference on Formal Grammar. Springer LNCS 9804, 257-272.
    [38]
    Andrey Mokhov, Neil Mitchell, and Simon Peyton Jones. 2018. Build Systems à La Carte. Proc. ACM Program. Lang. 2, ICFP, Article 79 ( July 2018 ), 29 pages. https://doi.org/10.1145/3236774
    [39]
    Dave Moore and Maria Ivanova Gorinova. 2018. Efect Handling for Composable Program Transformations in Edward2. In International Conference on Probabilistic Programming (PROBPROG).
    [40]
    Dereck C Oppen. 1980. Prettyprinting. Transactions on Programming Languages and Systems 2, 4 ( 1980 ), 465-483.
    [41]
    Leo Osvald, Grégory Essertel, Xilun Wu, Lilliam I González Alayón, and Tiark Rompf. 2016. Gentrification gone too far? afordable 2nd-class values for fun and (co-) efect. In Proceedings of the Conference on Object-Oriented Programming, Systems, Languages and Applications. ACM, New York, NY, USA, 234-251.
    [42]
    Tomas Petricek, Dominic Orchard, and Alan Mycroft. 2014. Coefects: A Calculus of Context-Dependent Computation. In Proceedings of the International Conference on Functional Programming (Gothenburg, Sweden). ACM, New York, NY, USA, 123-135. https://doi.org/10.1145/2628136.2628160
    [43]
    Du Phan, Neeraj Pradhan, and Martin Jankowiak. 2019. Composable efects for flexible and accelerated probabilistic programming in NumPyro. arXiv preprint arXiv: 1912. 11554 ( 2019 ).
    [44]
    Gordon D. Plotkin and Matija Pretnar. 2013. Handling Algebraic Efects. Logical Methods in Computer Science 9, 4 ( 2013 ).
    [45]
    Matija Pretnar. 2015. An introduction to algebraic efects and handlers. invited tutorial paper. Electronic Notes in Theoretical Computer Science 319 ( 2015 ), 19-35.
    [46]
    Lukas Rytz, Martin Odersky, and Philipp Haller. 2012. Lightweight Polymorphic Efects. In Proceedings of the European Conference on Object-Oriented Programming, James Noble (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 258-282.
    [47]
    Philipp Schuster and Jonathan Immanuel Brachthäuser. 2018. Typing, Representing, and Abstracting Control. In Proceedings of the Workshop on Type-Driven Development (St. Louis, Missouri, USA). ACM, New York, NY, USA, 14-24. https: //doi.org/10.1145/3240719.3241788
    [48]
    Philipp Schuster, Jonathan Immanuel Brachthäuser, and Klaus Ostermann. 2020. Compiling Efect Handlers in CapabilityPassing Style. 4, ICFP, Article 93 ( Aug. 2020 ), 28 pages. https://doi.org/10.1145/3408975
    [49]
    Dorai Sitaram. 1993. Handling Control. In Proceedings of the Conference on Programming Language Design and Implementation (Albuquerque, New Mexico, USA). ACM, New York, NY, USA, 147-155.
    [50]
    S Doaitse Swierstra and Olaf Chitil. 2009. Linear, bounded, functional pretty-printing. Journal of Functional Programming 19, 01 ( 2009 ), 1-16.
    [51]
    Fei Wang, Daniel Zheng, James Decker, Xilun Wu, Grégory M. Essertel, and Tiark Rompf. 2019. Demystifying Diferentiable Programming: Shift/Reset the Penultimate Backpropagator. Proc. ACM Program. Lang. 3, ICFP, Article 96 ( July 2019 ), 31 pages.
    [52]
    Andrew K. Wright and Matthias Felleisen. 1994. A syntactic approach to type soundness. Inf. Comput. 115, 1 (Nov. 1994 ), 38-94.
    [53]
    Nicolas Wu, Tom Schrijvers, and Ralf Hinze. 2014. Efect Handlers in Scope. In Proceedings of the Haskell Symposium (Gothenburg, Sweden) (Haskell '14). ACM, New York, NY, USA, 1-12.
    [54]
    Ningning Xie, Jonathan Immanuel Brachthäuser, Daniel Hillerström, Philipp Schuster, and Daan Leijen. 2020. Efect Handlers, Evidently. 4, ICFP, Article 99 ( Aug. 2020 ), 29 pages. https://doi.org/10.1145/3408981
    [55]
    Jeremy Yallop. 2017. Staged Generic Programming. Proc. ACM Program. Lang. 1, ICFP, Article 29 ( Aug. 2017 ), 29 pages.
    [56]
    Yizhou Zhang and Andrew C. Myers. 2019. Abstraction-safe Efect Handlers via Tunneling. Proc. ACM Program. Lang. 3, POPL, Article 5 ( Jan. 2019 ), 29 pages.
    [57]
    Yizhou Zhang, Guido Salvaneschi, Quinn Beightol, Barbara Liskov, and Andrew C. Myers. 2016. Accepting Blame for Safe Tunneled Exceptions. In Proceedings of the Conference on Programming Language Design and Implementation (Santa Barbara, CA, USA). ACM, New York, NY, USA, 281-295.

    Cited By

    View all
    • (2024)Specification and Verification for Unrestricted Algebraic Effects and HandlingProceedings of the ACM on Programming Languages10.1145/36746568:ICFP(909-937)Online publication date: 15-Aug-2024
    • (2024)Parallel Algebraic Effect HandlersProceedings of the ACM on Programming Languages10.1145/36746518:ICFP(756-788)Online publication date: 15-Aug-2024
    • (2024)Abstracting Effect Systems for Algebraic Effect HandlersProceedings of the ACM on Programming Languages10.1145/36746418:ICFP(455-484)Online publication date: 15-Aug-2024
    • Show More Cited By

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Proceedings of the ACM on Programming Languages
    Proceedings of the ACM on Programming Languages  Volume 4, Issue OOPSLA
    November 2020
    3108 pages
    EISSN:2475-1421
    DOI:10.1145/3436718
    Issue’s Table of Contents
    This work is licensed under a Creative Commons Attribution-NoDerivatives International 4.0 License.

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 13 November 2020
    Published in PACMPL Volume 4, Issue OOPSLA

    Permissions

    Request permissions for this article.

    Check for updates

    Badges

    Author Tags

    1. algebraic effects
    2. effect handlers
    3. effect polymorphism

    Qualifiers

    • Research-article

    Funding Sources

    • DFG

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

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

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Specification and Verification for Unrestricted Algebraic Effects and HandlingProceedings of the ACM on Programming Languages10.1145/36746568:ICFP(909-937)Online publication date: 15-Aug-2024
    • (2024)Parallel Algebraic Effect HandlersProceedings of the ACM on Programming Languages10.1145/36746518:ICFP(756-788)Online publication date: 15-Aug-2024
    • (2024)Abstracting Effect Systems for Algebraic Effect HandlersProceedings of the ACM on Programming Languages10.1145/36746418:ICFP(455-484)Online publication date: 15-Aug-2024
    • (2024)Grokking the Sequent Calculus (Functional Pearl)Proceedings of the ACM on Programming Languages10.1145/36746398:ICFP(395-425)Online publication date: 15-Aug-2024
    • (2024)Degrees of Separation: A Flexible Type System for Safe ConcurrencyProceedings of the ACM on Programming Languages10.1145/36498538:OOPSLA1(1181-1207)Online publication date: 29-Apr-2024
    • (2024)Explicit Effects and Effect Constraints in ReMLProceedings of the ACM on Programming Languages10.1145/36329218:POPL(2370-2394)Online publication date: 5-Jan-2024
    • (2024)Securing Verified IO Programs Against Unverified Code in F*Proceedings of the ACM on Programming Languages10.1145/36329168:POPL(2226-2259)Online publication date: 5-Jan-2024
    • (2024)Soundly Handling LinearityProceedings of the ACM on Programming Languages10.1145/36328968:POPL(1600-1628)Online publication date: 5-Jan-2024
    • (2024)Asymptotic speedup via effect handlersJournal of Functional Programming10.1017/S095679682400003034Online publication date: 5-Apr-2024
    • (2024)A framework for higher-order effects & handlersScience of Computer Programming10.1016/j.scico.2024.103086234:COnline publication date: 1-May-2024
    • 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