Abstract
Effect handlers are a program structuring paradigm with rising popularity in the functional programming language community and can express many advanced control flow abstractions. We present the first implementation of effect handlers for Java - an imperative, object oriented programming language. Our framework consists of three core components: A type selective CPS transformation via JVM bytecode transformation, an implementation of delimited continuations on top of the bytecode transformation and finally a library for effect handlers in terms of delimited continuations.
Supplemental Material
- Andrej Bauer and Matija Pretnar. 2013. An effect system for algebraic effects and handlers. In International Conference on Algebra and Coalgebra in Computer Science. Springer, 1–16.Google Scholar
Cross Ref
- Andrej Bauer and Matija Pretnar. 2015. Programming with algebraic effects and handlers. Journal of Logical and Algebraic Methods in Programming 84, 1 (2015), 108–123.Google Scholar
Cross Ref
- Gavin Bierman, Claudio Russo, Geoffrey Mainland, Erik Meijer, and Mads Torgersen. 2012. Pause’n’Play: Formalizing Asynchronous C#. In Proceedings of the European Conference on Object-Oriented Programming. Springer-Verlag, 233–257. Google Scholar
Digital Library
- Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2017. Handle with Care: Relational Interpretation of Algebraic Effects and Handlers. In Proceedings of the Symposium on Principles of Programming Languages. ACM.Google Scholar
Digital Library
- Jonathan Immanuel Brachthäuser and Philipp Schuster. 2017. Effekt: Extensible Algebraic Effects in Scala (Short Paper). In Proceedings of the International Symposium on Scala. ACM. Google Scholar
Digital Library
- Edwin Brady. 2013. Programming and Reasoning with Algebraic Effects and Dependent Types. In Proceedings of the International Conference on Functional Programming. ACM, 133–144. Google Scholar
Digital Library
- Jacques Carette, Oleg Kiselyov, and Chung-Chieh Shan. 2007. Finally Tagless, Partially Evaluated. In Proceedings of the Asian Symposium on Programming Languages and Systems. Springer LNCS 4807, 222–238. Google Scholar
Digital Library
- Melvin E Conway. 1963. Design of a separable transition-diagram compiler. Commun. ACM 6, 7 (1963). Google Scholar
Digital Library
- Stephen Dolan, Spiros Eliopoulos, Daniel Hillerström, Anil Madhavapeddy, KC Sivaramakrishnan, and Leo White. 2017. Concurrent system programming with effect handlers. In Proceedings of the Symposium on Trends in Functional Programming.Google Scholar
- Stephen Dolan, Leo White, KC Sivaramakrishnan, Jeremy Yallop, and Anil Madhavapeddy. 2015. Effective concurrency through algebraic effects. In OCaml Workshop.Google Scholar
- Iulian Dragos, Antonio Cunei, and Jan Vitek. 2007. Continuations in the Java virtual machine. In Second ECOOP Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems (ICOOOLPS 2007). Technische Universität Berlin.Google Scholar
- R Kent Dyvbig, Simon Peyton Jones, and Amr Sabry. 2007. A monadic framework for delimited continuations. Journal of Functional Programming 17, 6 (2007), 687–730. Google Scholar
Digital Library
- Michael Eichberg and Ben Hermann. 2014. A Software Product Line for Static Analyses: The OPAL Framework. In Proceedings of the 3rd ACM SIGPLAN International Workshop on the State of the Art in Java Program Analysis (SOAP ’14). ACM. Google Scholar
Digital Library
- Steven E. Ganz, Daniel P. Friedman, and Mitchell Wand. 1999. Trampolined Style. In Proceedings of the International Conference on Functional Programming. ACM, 18–27. Google Scholar
Digital Library
- R. Hieb and R. Kent Dybvig. 1990. Continuations and Concurrency. In Proceedings of the Second ACM SIGPLAN Symposium on Principles & Practice of Parallel Programming (PPOPP ’90). ACM, 128–136. Google Scholar
Digital Library
- Daniel Hillerström, Sam Lindley, Bob Atkey, and KC Sivaramakrishnan. 2017. Continuation Passing Style for Effect Handlers. In Formal Structures for Computation and Deduction (LIPIcs), Vol. 84. Schloss Dagstuhl–Leibniz-Zentrum für Informatik.Google Scholar
- Paul Hudak. 1998. Modular Domain Specific Languages and Tools. In Proceedings of the Conference on Software Reuse. IEEE Computer Society Press, 134–142. Google Scholar
Digital Library
- Ohad Kammar, Sam Lindley, and Nicolas Oury. 2013. Handlers in Action. In Proceedings of the International Conference on Functional Programming. ACM, 145–158. Google Scholar
Digital Library
- Oleg Kiselyov and Hiromi Ishii. 2015. Freer Monads, More Extensible Effects. In Proceedings of the Haskell Symposium. ACM, 94–105. Google Scholar
Digital Library
- Oleg Kiselyov, Amr Sabry, and Cameron Swords. 2013. Extensible Effects: An Alternative to Monad Transformers. In Proceedings of the Haskell Symposium. ACM, 59–70. Google Scholar
Digital Library
- Oleg Kiselyov and KC Sivaramakrishnan. 2016. Eff directly in OCaml. In ML Workshop.Google Scholar
- Daan Leijen. 2014. Koka: Programming with Row Polymorphic Effect Types. In Proceedings of the Workshop on Mathematically Structured Functional Programming.Google Scholar
Cross Ref
- Daan Leijen. 2016. Algebraic Effects for Functional Programming. Technical Report. MSR-TR-2016-29. Microsoft Research technical report.Google Scholar
- Daan Leijen. 2017a. Implementing Algebraic Effects in C. In Proceedings of the Asian Symposium on Programming Languages and Systems. Springer International Publishing, Cham, Switzerland, 339–363.Google Scholar
Cross Ref
- Daan Leijen. 2017b. Structured Asynchrony with Algebraic Effects. In Proceedings of the Workshop on Type-Driven Development. ACM, 16–29. Google Scholar
Digital Library
- Daan Leijen. 2017c. Type directed compilation of row-typed algebraic effects. In Proceedings of the Symposium on Principles of Programming Languages. 486–499. Google Scholar
Digital Library
- Sam Lindley. 2018. Encapsulating effects, In Algebraic Effect Handlers go Mainstream (Dagstuhl Seminar 18172). Dagstuhl Reports 8, 4.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. ACM, 500–514. Google Scholar
Digital Library
- Florian Loitsch. 2007. Exceptional continuations in JavaScript. In Workshop on Scheme and Functional Programming.Google Scholar
- Bruno C. d. S. Oliveira and William R. Cook. 2012. Extensibility for the Masses: Practical Extensibility with Object Algebras. In Proceedings of the European Conference on Object-Oriented Programming. Springer LNCS 7313, 2–27. Google Scholar
Digital Library
- Greg Pettyjohn, John Clements, Joe Marshall, Shriram Krishnamurthi, and Matthias Felleisen. 2005. Continuations from Generalized Stack Inspection. In Proceedings of the International Conference on Functional Programming. ACM, 216–227. Google Scholar
Digital Library
- Gordon Plotkin and John Power. 2003. Algebraic operations and generic effects. Applied Categorical Structures 11, 1 (2003), 69–94.Google Scholar
- Gordon Plotkin and Matija Pretnar. 2009. Handlers of algebraic effects. In European Symposium on Programming. SpringerVerlag, 80–94. Google Scholar
Digital Library
- Joe Gibbs Politz, Alejandro Martinez, Matthew Milano, Sumner Warren, Daniel Patterson, Junsong Li, Anand Chitipothu, and Shriram Krishnamurthi. 2013. Python: The Full Monty. In Proceedings of the Conference on Object-Oriented Programming, Systems, Languages and Applications. ACM, 217–232. Google Scholar
Digital Library
- Ron Pressler. 2017. Loom Project: Fibers and Continuations for the Java Virtual Machine. OpenJDK Project. HotSpot Group. http://mail.openjdk.java.net/pipermail/discuss/2017-September/004390.htmlGoogle Scholar
- Aleksandar Prokopec and Fengyun Liu. 2018. Theory and practice of coroutines with snapshots. In Proceedings of the European Conference on Object-Oriented Programming. Schloss Dagstuhl–Leibniz-Zentrum für Informatik.Google Scholar
- John C. Reynolds. 1972. Definitional Interpreters for Higher-Order Programming Languages. In Proceedings of the ACM annual conference. ACM, 717–740. Google Scholar
Digital Library
- Tatsurou Sekiguchi, Takahiro Sakamoto, and Akinori Yonezawa. 2001. Advances in Exception Handling Techniques. Springer-Verlag, Heidelberg, Berlin, Germany, Chapter Portable Implementation of Continuation Operators in Imperative Languages by Exception Handling, 217–233. Google Scholar
Digital Library
- Lukas Stadler, Christian Wimmer, Thomas Würthinger, Hanspeter Mössenböck, and John Rose. 2009. Lazy continuations for Java virtual machines. In Proceedings of the International Conference on Principles and Practice of Programming in Java. ACM, 143–152. Google Scholar
Digital Library
- Nicolas Wu and Tom Schrijvers. 2015. Fusion for Free - Efficient Algebraic Effect Handlers. In Proceedings of the Conference on Mathematics of Program Construction. Springer LNCS 9129.Google Scholar
Index Terms
Effect handlers for the masses
Recommendations
Liberating effects with rows and handlers
TyDe 2016: Proceedings of the 1st International Workshop on Type-Driven DevelopmentAlgebraic effects and effect handlers provide a modular abstraction for effectful programming. They support user-defined effects, as in Haskell, in conjunction with direct-style effectful programming, as in ML. They also present a structured interface ...
Heuristics Entwined with Handlers Combined: From Functional Specification to Logic Programming Implementation
PPDP '14: Proceedings of the 16th International Symposium on Principles and Practice of Declarative ProgrammingA long-standing problem in logic programming is how to cleanly separate logic and control. While solutions exist, they fall short in one of two ways: some are too intrusive, because they require significant changes to Prolog's underlying implementation; ...
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 ...






Comments