22.04.18 - 27.04.18, Seminar 18172

Algebraic Effect Handlers go Mainstream

The following text appeared on our web pages prior to the seminar, and was included as part of the invitation.


Languages like C#, C++, or JavaScript support complex control flow statements like exception handling, iterators (yield), and even asynchrony (asyncawait) through special extensions. For exceptions, the runtime needs to be extended with exception handling stack frames. For iterators and asynchrony, the situation is more involved, as the compiler needs to turn regular code into stack restoring state machines. Furthermore, these features need to interact as expected, e.g. finally blocks must not be forgotten in the state machines for iterators. And all of this work needs to be done again for the next control flow abstraction that comes along.

Or we can use algebraic effect handlers! This single mechanism generalizes all the control flow abstractions listed above and more, composes freely, has simple operational semantics, and can be efficiently compiled, since there is just one mechanism that needs to be supported well. Handlers allow programmers to keep the code in direct-style, which is easy to reason about, and empower library writers to implement various high-level abstractions without special extensions.

The idea of algebraic effects handlers has already been experimented with in the form of small research languages and libraries in several mainstream languages, including OCaml, Haskell, Clojure, and Scala. The next step, and the aim of this seminar, is to seriously consider adoption by mainstream languages including both functional languages such as OCaml or Haskell, as well as languages like JavaScript and the JVM and .NET ecosystems.

Topics of the seminar will include:

  • Presenting ways algebraic effect handlers solve current issues and express legacy abstractions in mainstream programming languages.
  • Discussing ways of introducing handlers into existing mainstream languages and ecosystems that have grown around them, and exploring ways of presenting handlers to the programmer.
  • Analysing issues that have surfaced in initial prototypes such as interaction with other language features, runtime performance, or concurrent execution, and surveying recent theoretical developments.
  • Showcasing programs such as a high performance web server or a user interface library, which illustrate the benefit of handler-oriented architecture.

Creative Commons BY 3.0 DE
Daan Leijen, Matija Pretnar, Tom Schrijvers, and KC Sivaramakrishnan