Handlers in Action
📜 Abstract
Plotkin and Pretnar’s handlers for algebraic effects occupy a sweet spot in the design space of abstractions for effectful computation. By separating effect signatures from their implementation, algebraic effects provide a high degree of modularity, allowing programmers to express effectful programs independently of the concrete interpretation of their effects. A handler is an interpretation of the effects of an algebraic computation. The handler abstraction adapts well to multiple settings: pure or impure, strict or lazy, static types or dynamic types. This is a position paper whose main aim is to popularise the handler abstraction. We give a gentle introduction to its use, a collection of illustrative examples, and a straightforward operational semantics. We describe our Haskell implementation of handlers in detail, outline the ideas behind our OCaml, SML, and Racket implementations, and present experimental results comparing handlers with existing code.
✨ Summary
The paper presents algebraic effects and handlers as an alternative foundation for modular effectful programming. Its central distinction is between abstract effect operations and handlers that provide concrete interpretations, allowing effects to be composed and instantiated independently rather than fixed through monad-transformer-stack structure.
The authors illustrate the approach with handlers for state, logging, nondeterminism, failure, input processing, pipes, and aspect-oriented behavior. They distinguish closed handlers, which interpret a complete effect signature, from open handlers, which handle selected operations and forward the rest. They also compare deep handlers, which automatically re-handle resumed continuations, with shallow handlers, which require explicit recursive handling.
The paper introduces λ_eff, a higher-order call-by-push-value calculus with effect operations and handlers. It gives a small-step operational semantics, a type-and-effect system, and proofs of termination and type soundness for well-typed programs. The implementation discussion presents free-monad, codensity-monad, continuation-monad, and delimited-continuation techniques, including a Haskell implementation using type classes and type families and related implementations for OCaml, SML, and Racket.
The benchmarks show that the continuation-monad implementation is generally substantially faster than the free- and codensity-monad implementations, although it remains slower than specialized baseline code in several tests. In the aspect-oriented programming benchmark, handler-based, mixin-based, and hand-coded implementations have nearly identical performance. (homepages.inf.ed.ac.uk)
The paper had documented subsequent influence. The ACM SIGPLAN citation for its 2023 Most Influential ICFP Paper Award credits it with drawing broader attention to handlers, providing an operational semantics and effect system, and motivating subsequent work and implementations. (sigplan.org) Its research impact is also recorded in a 2021 UK Research Excellence Framework case study, which lists the paper among the cited foundations of later effect-handler research. (results2021.ref.ac.uk) Practically, the implementation ideas remain represented in later effect-handler benchmarking infrastructure, where “Handlers in Action” is included alongside systems such as Eff, Effekt, Koka, and OCaml implementations. (github.com) Bibliographic records confirm its publication as an ICFP 2013 conference paper in ACM SIGPLAN Notices, volume 48, issue 9, pages 145–158. (research.ed.ac.uk)