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.
Supplemental Material
- 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.Google Scholar
- 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.Google Scholar
Cross Ref
- 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.Google Scholar
Cross Ref
- 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.Google Scholar
Digital Library
- 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.Google Scholar
- 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.Google Scholar
- 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.Google Scholar
Digital Library
- 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.Google Scholar
- 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 Google Scholar
Digital Library
- 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 Google Scholar
Digital Library
- 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 Google Scholar
Cross Ref
- 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.Google Scholar
- Jonathan Immanuel Brachthäuser and Daan Leijen. 2019. Programming with Implicit Values, Functions, and Control. Technical Report MSR-TR-2019-7. Microsoft Research.Google Scholar
- Edwin Brady. 2013. Idris, a general-purpose dependently typed programming language: Design and implementation. Journal of Functional Programming 23, 5 ( 2013 ), 552-593.Google Scholar
Cross Ref
- 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 Google Scholar
Cross Ref
- Olivier Danvy and Andrzej Filinski. 1989. A functional abstraction of typed contexts. DIKU Rapport 89 /12, DIKU, University of Copenhagen ( 1989 ).Google Scholar
- 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.Google Scholar
- Stephen Dolan, Leo White, and Anil Madhavapeddy. 2014. Multicore OCaml. In OCaml Workshop.Google Scholar
- Stephen Dolan, Leo White, KC Sivaramakrishnan, Jeremy Yallop, and Anil Madhavapeddy. 2015. Efective concurrency through algebraic efects. In OCaml Workshop.Google Scholar
- 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.Google Scholar
- 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 Google Scholar
Digital Library
- 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.Google Scholar
Digital Library
- 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.Google Scholar
- 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.Google Scholar
Digital Library
- 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.Google Scholar
- 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.Google Scholar
Digital Library
- 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.Google Scholar
Digital Library
- Daan Leijen. 2005. Extensible records with scoped labels. In Proceedings of the Symposium on Trends in Functional Programming. 297-312.Google Scholar
- Daan Leijen. 2014. Koka: Programming with Row Polymorphic Efect Types. In Proceedings of the Workshop on Mathematically Structured Functional Programming.Google Scholar
Cross Ref
- Daan Leijen. 2016. Algebraic Efects for Functional Programming. Technical Report. MSR-TR-2016-29. Microsoft Research technical report.Google Scholar
- 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.Google Scholar
- 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.Google Scholar
- Daan Leijen. 2018a. Algebraic Efect Handlers with Resources and Deep Finalization. Technical Report MSR-TR-2018-10. Microsoft Research. 35 pages.Google Scholar
- 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.Google Scholar
- 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.Google Scholar
- 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.Google Scholar
Digital Library
- 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.Google Scholar
- 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 Google Scholar
Digital Library
- Dave Moore and Maria Ivanova Gorinova. 2018. Efect Handling for Composable Program Transformations in Edward2. In International Conference on Probabilistic Programming (PROBPROG).Google Scholar
- Dereck C Oppen. 1980. Prettyprinting. Transactions on Programming Languages and Systems 2, 4 ( 1980 ), 465-483.Google Scholar
Digital Library
- 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.Google Scholar
- 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 Google Scholar
Digital Library
- Du Phan, Neeraj Pradhan, and Martin Jankowiak. 2019. Composable efects for flexible and accelerated probabilistic programming in NumPyro. arXiv preprint arXiv: 1912. 11554 ( 2019 ).Google Scholar
- Gordon D. Plotkin and Matija Pretnar. 2013. Handling Algebraic Efects. Logical Methods in Computer Science 9, 4 ( 2013 ).Google Scholar
- Matija Pretnar. 2015. An introduction to algebraic efects and handlers. invited tutorial paper. Electronic Notes in Theoretical Computer Science 319 ( 2015 ), 19-35.Google Scholar
- 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.Google Scholar
- 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 Google Scholar
Digital Library
- 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 Google Scholar
Digital Library
- 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.Google Scholar
- S Doaitse Swierstra and Olaf Chitil. 2009. Linear, bounded, functional pretty-printing. Journal of Functional Programming 19, 01 ( 2009 ), 1-16.Google Scholar
- 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.Google Scholar
- Andrew K. Wright and Matthias Felleisen. 1994. A syntactic approach to type soundness. Inf. Comput. 115, 1 (Nov. 1994 ), 38-94.Google Scholar
Digital Library
- 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.Google Scholar
- 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 Google Scholar
Digital Library
- Jeremy Yallop. 2017. Staged Generic Programming. Proc. ACM Program. Lang. 1, ICFP, Article 29 ( Aug. 2017 ), 29 pages.Google Scholar
Digital Library
- 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.Google Scholar
- 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.Google Scholar
Index Terms
Effects as capabilities: effect handlers and lightweight effect polymorphism
Recommendations
Effect handlers, evidently
Algebraic effect handlers are a powerful way to incorporate effects in a programming language. Sometimes perhaps even _too_ powerful. In this article we define a restriction of general effect handlers with _scoped resumptions_. We argue one can still ...
First-class names for effect handlers
Algebraic effects and handlers are a promising technique for incorporating composable computational effects into functional programming languages. Effect handlers enable concisely programming with different effects, but they do not offer a convenient ...
Contextual modal types for algebraic effects and handlers
Programming languages with algebraic effects often track the computations’ effects using type-and-effect systems. In this paper, we propose to view an algebraic effect theory of a computation as a variable context; consequently, we propose to track ...






Comments