Abstract
Structuring control flow is an essential task almost every programmer faces on a daily basis. At the same time, the control flow of software applications is becoming increasingly complicated, motivating languages to include more and more features like asynchronous programming and generators. Effect handlers are a promising alternative since they can express many of these features as libraries. To bring effect handlers closer to the software engineering practice, we present capability passing as an implementation technique for effect handlers. Capability passing provides the basis for the integration of effect handlers into mainstream object-oriented programming languages and thereby unlocks novel modularization strategies. It also enables programmers to apply lexical reasoning about effects and gives rise to a new form of effect polymorphism. Finally, it paves the path for efficient compilation strategies of control effects.
Chapter PDF
References
Ahman, D., Pretnar, M.: Asynchronous effects. Proc. ACM Program. Lang. 5(POPL) (2021). https://doi.org/10.1145/3434305
Bauer, A., Pretnar, M.: An effect system for algebraic effects and handlers. In: International Conference on Algebra and Coalgebra in Computer Science, pp. 1–16. Springer, Berlin, Heidelberg (2013)
Bauer, A., Pretnar, M.: Programming with algebraic effects and handlers. J. Logical Algebraic Methods Program. 84(1), 108–123 (2015)
Biernacki, D., Piróg, M., Polesiuk, P., Sieczkowski, F.: Abstracting algebraic effects. Proc. ACM Program. Lang. 3(POPL), 6:1–6:28 (2019)
Biernacki, D., Piróg, M., Polesiuk, P., Sieczkowski, F.: Binders by day, labels by night: effect instances via lexically scoped handlers. Proc. ACM Program. Lang. 4(POPL) (2019). https://doi.org/10.1145/3371116
Brachthäuser, J.I., Schuster, P.: Effekt: Extensible algebraic effects in Scala (short paper). In: Proceedings of the International Symposium on Scala. ACM, New York (2017). https://doi.org/10.1145/3136000.3136007
Brachthäuser, J.I., Schuster, P., Ostermann, K.: Effect handlers for the masses. Proc. ACM Program. Lang. 2(OOPSLA), 111:1–111:27 (2018). https://doi.org/10.1145/3276481
Brachthäuser, J.I., Schuster, P., Ostermann, K.: Effects as capabilities: effect handlers and lightweight effect polymorphism. Proc. ACM Program. Lang. 4(OOPSLA) (2020). https://doi.org/10.1145/3428194
Brachthäuser, J.I., Schuster, P., Ostermann, K.: Effekt: capability-passing style for type- and effect-safe, extensible effect handlers in Scala. J. Funct. Program. (2020). https://doi.org/10.1017/S0956796820000027
Brachthäuser, J.I.: Towards naturalistic EDSLs using algebraic effects (2017). Presentation at Domain-Specific Language Design and Implementation (DSLDI)
Brachthäuser, J.I.: Design and implementation of effect handlers for object-oriented programming languages. Ph.D. Thesis, University of Tübingen, Germany (2020). https://doi.org/10.15496/publikation-43400
Brachthäuser, J.I., Leijen, D.: Programming with implicit values, functions, and control. Tech. Rep. MSR-TR-2019-7, Microsoft Research (2019)
Brady, E.: Programming and reasoning with algebraic effects and dependent types. In: Proceedings of the International Conference on Functional Programming, pp. 133–144. ACM, New York (2013)
Convent, L., Lindley, S., McBride, C., McLaughlin, C.: Doo bee doo bee doo. J. Funct. Program. 30, e9 (2020). https://doi.org/10.1017/S0956796820000039
Danvy, O., Filinski, A.: Abstracting control. In: Proceedings of the Conference on LISP and Functional Programming, pp. 151–160. ACM, New York (1990)
Dennis, J.B., Van Horn, E.C.: Programming semantics for multiprogrammed computations. Commun. ACM 9(3), 143–155 (1966)
Dolan, S., Eliopoulos, S., Hillerström, D., Madhavapeddy, A., Sivaramakrishnan, K., White, L.: Concurrent system programming with effect handlers. In: Proceedings of the Symposium on Trends in Functional Programming. Springer LNCS 10788 (2017)
Dolan, S., Eliopoulos, S., Hillerström, D., Madhavapeddy, A., Sivaramakrishnan, K., White, L.: Effectively tackling the awkward squad. In: ML Workshop (2017)
Dolan, S., Muralidharan, S., Gregg, D.: Compiler support for lightweight context switching. ACM Trans. Archit. Code Optim. 9(4), 36:1–36:25 (2013)
Dolan, S., White, L., Madhavapeddy, A.: Multicore OCaml. In: OCaml Workshop (2014)
Dolan, S., White, L., Sivaramakrishnan, K., Yallop, J., Madhavapeddy, A.: Effective concurrency through algebraic effects. In: OCaml Workshop (2015)
Dybvig, R.K.: The development of chez scheme. In: Proceedings of the Eleventh ACM SIGPLAN International Conference on Functional Programming, ICFP ’06, pp. 1–12. ACM, New York (2006). https://doi.org/10.1145/1159803.1159805
Dybvig, R.K., Peyton Jones, S.L., Sabry, A.: A monadic framework for delimited continuations. J. Funct. Program. 17(6), 687–730 (2007)
Fischer, M.J.: Lambda calculus schemata. In: Proceedings of ACM Conference on Proving Assertions About Programs, pp. 104–109. ACM, New York (1972)
Gosling, J., Joy, B., Steele, G.L.: The Java Language Specification. Addison-Wesley Publishing, Boston (1996)
Gunter, C.A., Rémy, D., Riecke, J.G.: A generalization of exceptions and control in ML-like languages. In: Proceedings of the Conference on Functional Programming Languages and Computer Architecture, pp. 12–23. ACM, New York (1995)
Hillerström, D., Lindley, S., Atkey, B., Sivaramakrishnan, K.: Continuation passing style for effect handlers. In: Formal Structures for Computation and Deduction, LIPIcs, vol. 84. Schloss Dagstuhl–Leibniz-Zentrum für Informatik (2017)
Inostroza, P., van der Storm, T.: JEff: Objects for effect. In: Proceedings of the 2018 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software, Onward! 2018. ACM, New York (2018)
Kammar, O., Lindley, S., Oury, N.: Handlers in action. In: Proceedings of the International Conference on Functional Programming, pp. 145–158. ACM, New York (2013)
Kiselyov, O.: Delimited control in OCaml, abstractly and concretely. Theor. Comput. Sci. 435, 56–76 (2012)
Kiselyov, O., Sabry, A., Swords, C.: Extensible effects: an alternative to monad transformers. In: Proceedings of the Haskell Symposium, pp. 59–70. ACM, New York (2013)
Kiselyov, O., Sivaramakrishnan, K.: Eff directly in OCaml. In: ML Workshop (2016)
Leijen, D.: Koka: Programming with row polymorphic effect types. In: Proceedings of the Workshop on Mathematically Structured Functional Programming (2014)
Leijen, D.: Algebraic effects for functional programming. Tech. rep., MSR-TR-2016-29. Microsoft Research technical report (2016)
Leijen, D.: Implementing algebraic effects in C. In: Proceedings of the Asian Symposium on Programming Languages and Systems, pp. 339–363. Springer, Cham (2017)
Leijen, D.: Structured asynchrony with algebraic effects. In: Proceedings of the Workshop on Type-Driven Development, pp. 16–29. ACM, New York (2017)
Leijen, D.: Type directed compilation of row-typed algebraic effects. In: Proceedings of the Symposium on Principles of Programming Languages, pp. 486–499. ACM, New York (2017)
Lewis, J.R., Launchbury, J., Meijer, E., Shields, M.B.: Implicit parameters: dynamic scoping with static types. In: Proceedings of the Symposium on Principles of Programming Languages, pp. 108–118. ACM, New York (2000)
Lindley, S.: Encapsulating effects. Dagstuhl Rep. 8(4), 114–118 (2018)
Lindley, S., McBride, C., McLaughlin, C.: Do be do be do. In: Proceedings of the Symposium on Principles of Programming Languages, pp. 500–514. ACM, New York (2017)
Madsen, M., Lhoták, O., Tip, F.: A model for reasoning about javascript promises. Proc. ACM Program. Lang. 1(OOPSLA) (2017). https://doi.org/10.1145/3133910
McCarthy, J.: Recursive functions of symbolic expressions and their computation by machine, Part I. Commun. ACM 3(4), 184–195 (1960). https://doi.org/10.1145/367177.367199
Melicher, D., Shi, Y., Potanin, A., Aldrich, J.: A capability-based module system for authority control. In: 31st European Conference on Object-Oriented Programming (ECOOP 2017). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik (2017)
Miller, M.S.: Robust composition: Towards a unified approach to access control and concurrency control. Ph.D. Thesis, Johns Hopkins University, Baltimore, Maryland, USA (2006). AAI3245526
Osvald, L., Essertel, G., Wu, X., Alayón, L.I.G., Rompf, T.: Gentrification gone too far? affordable 2nd-class values for fun and (co-) effect. In: Proceedings of the Conference on Object-Oriented Programming, Systems, Languages and Applications, pp. 234–251. ACM, New York (2016)
Plotkin, G., Power, J.: Algebraic operations and generic effects. Appl. Categorical Struct. 11(1), 69–94 (2003)
Plotkin, G., Pretnar, M.: Handlers of algebraic effects. In: European Symposium on Programming, pp. 80–94. Springer, Berlin (2009)
Plotkin, G.D., Pretnar, M.: Handling algebraic effects. Logical Methods Comput. Sci. 9(4), 1–36 (2013)
Pretnar, M., Saleh, A.H.S., Faes, A., Schrijvers, T.: Efficient compilation of algebraic effects and handlers. Tech. rep., Department of Computer Science, KU Leuven; Leuven, Belgium (2017)
Reynolds, J.C.: Definitional interpreters for higher-order programming languages. In: Proceedings of the ACM Annual Conference, pp. 717–740. ACM, New York (1972)
Reynolds, J.C.: Types, abstraction and parametric polymorphism. In: Proceedings of the IFIP World Computer Congress, pp. 513–523. Elsevier (North-Holland), Amsterdam (1983)
Schuster, P., Brachthäuser, J.I.: Typing, representing, and abstracting control. In: Proceedings of the Workshop on Type-Driven Development, pp. 14–24. ACM, New York (2018). https://doi.org/10.1145/3240719.3241788
Schuster, P., Brachthäuser, J.I., Ostermann, K.: Compiling effect handlers in capability-passing style. Proc. ACM Program. Lang. 4(ICFP) (2020). https://doi.org/10.1145/3408975
Wadler, P.: Theorems for free! In: Proceedings of the Conference on Functional Programming Languages and Computer Architecture, pp. 347–359. ACM, New York (1989)
Wu, N., Schrijvers, T.: Fusion for free—efficient algebraic effect handlers. In: Proceedings of the Conference on Mathematics of Program Construction. Springer LNCS 9129 (2015)
Xie, N., Brachthäuser, J.I., Hillerström, D., Schuster, P., Leijen, D.: Effect handlers, evidently. Proc. ACM Program. Lang. 4(ICFP) (2020). https://doi.org/10.1145/3408981
Xie, N., Leijen, D.: Generalized evidence passing for effect handlers. Tech. Rep. MSR-TR-2021-5, Microsoft (2021). https://www.microsoft.com/en-us/research/publication/generalized-evidence-passing-for-effect-handlers/. V2, 2021-04-24
Zhang, Y., Myers, A.C.: Abstraction-safe effect handlers via tunneling. Proc. ACM Program. Lang. 3(POPL), 5:1–5:29 (2019)
Zhang, Y., Salvaneschi, G., Beightol, Q., Liskov, B., Myers, A.C.: Accepting blame for safe tunneled exceptions. In: Proceedings of the Conference on Programming Language Design and Implementation, pp. 281–295. ACM, New York (2016)
Zhang, Y., Salvaneschi, G., Myers, A.C.: Handling bidirectional control flow. Proc. ACM Program. Lang. 4(OOPSLA) (2020). https://doi.org/10.1145/3428207
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.
The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.
Copyright information
© 2022 The Author(s)
About this chapter
Cite this chapter
Brachthäuser, J.I. (2022). What You See Is What You Get: Practical Effect Handlers in Capability-Passing Style. In: Felderer, M., et al. Ernst Denert Award for Software Engineering 2020. Springer, Cham. https://doi.org/10.1007/978-3-030-83128-8_3
Download citation
DOI: https://doi.org/10.1007/978-3-030-83128-8_3
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-83127-1
Online ISBN: 978-3-030-83128-8
eBook Packages: Computer ScienceComputer Science (R0)