From Capabilities to Regions: Enabling Efficient Compilation of Lexical Effect Handlers
Marius Müller, Philipp Schuster, Jonathan Lindegaard Starup, Klaus Ostermann, Jonathan Immanuel Brachthäuser
Abstract
Effect handlers are a high-level abstraction that enables programmers to use effects in a structured way. They have gained a lot of popularity within academia and subsequently also in industry. However, the abstraction often comes with a significant runtime cost and there has been intensive research recently on how to reduce this price.
A promising approach in this regard is to implement effect handlers using a CPS translation and to provide sufficient information about the nesting of handlers. With this information the CPS translation can decide how effects have to be lifted through handlers, i.e., which handlers need to be skipped, in order to handle the effect at the correct place. A structured way to make this information available is to use a calculus with a region system and explicit subregion evidence. Such calculi, however, are quite verbose, which makes them impractical to use as a source-level language.
We present a method to infer the lifting information for a calculus underlying a source-level language. This calculus uses second-class capabilities for the safe use of effects. To do so, we define a typed translation to a calculus with regions and evidence and we show that this lift-inference translation is typability-and semantics-preserving. On the one hand, this exposes the precise relation between the second-class property and the structure given by regions. On the other hand, it closes a gap in a compiler pipeline enabling efficient compilation of the source-level language. We have implemented lift inference in this compiler pipeline and conducted benchmarks which indicate that the approach is indeed working.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
7 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- A Lightweight Type-and-Effect System for Invalidation Safety: Tracking Permanent and Temporary Invalidation with Constraint-Based Subtype Inference cites Effects, capabilities, and boxes: from scope-based reasoning to type-based reasoning and back
- A Lightweight Type-and-Effect System for Invalidation Safety: Tracking Permanent and Temporary Invalidation with Constraint-Based Subtype Inference cites Effects as capabilities: effect handlers and lightweight effect polymorphism
- Lexical Effect Handlers, Directly cites Retrofitting effect handlers onto OCaml
- Lexical Effect Handlers, Directly cites Effects, capabilities, and boxes: from scope-based reasoning to type-based reasoning and back
- Lexical Effect Handlers, Directly cites Effects as capabilities: effect handlers and lightweight effect polymorphism
- Lexical Effect Handlers, Directly cites From folklore to fact: comparing implementations of stacks and continuations
- Lexical Effect Handlers, Directly cites Binders by day, labels by night: effect instances via lexically scoped handlers
- Retrofitting effect handlers onto OCaml cites From folklore to fact: comparing implementations of stacks and continuations
- Retrofitting effect handlers onto OCaml cites Binders by day, labels by night: effect instances via lexically scoped handlers
- Qualified Types with Boolean Algebras cites Lexical Effect Handlers, Directly
- Qualified Types with Boolean Algebras cites Effects, capabilities, and boxes: from scope-based reasoning to type-based reasoning and back
- Qualified Types with Boolean Algebras cites Effects as capabilities: effect handlers and lightweight effect polymorphism
- Zero-Overhead Lexical Effect Handlers cites Lexical Effect Handlers, Directly
- Zero-Overhead Lexical Effect Handlers cites Retrofitting effect handlers onto OCaml
- Zero-Overhead Lexical Effect Handlers cites Effects as capabilities: effect handlers and lightweight effect polymorphism
- Zero-Overhead Lexical Effect Handlers cites Binders by day, labels by night: effect instances via lexically scoped handlers
- Effects, capabilities, and boxes: from scope-based reasoning to type-based reasoning and back cites Effects as capabilities: effect handlers and lightweight effect polymorphism
- Effects, capabilities, and boxes: from scope-based reasoning to type-based reasoning and back cites Binders by day, labels by night: effect instances via lexically scoped handlers
- Virtualizing Continuations cites Lexical Effect Handlers, Directly
- Virtualizing Continuations cites Retrofitting effect handlers onto OCaml
- Virtualizing Continuations cites Zero-Overhead Lexical Effect Handlers
- Virtualizing Continuations cites Effects, capabilities, and boxes: from scope-based reasoning to type-based reasoning and back
- Virtualizing Continuations cites From folklore to fact: comparing implementations of stacks and continuations
- Virtualizing Continuations cites Binders by day, labels by night: effect instances via lexically scoped handlers
- Effects as capabilities: effect handlers and lightweight effect polymorphism cites Binders by day, labels by night: effect instances via lexically scoped handlers
Cited by top-tier papers7
- Lexical Effect Handlers, DirectlyCong Ma, Zhaoyi Ge, Edward Lee, Yizhou ZhangOOPSLA 2024 · 7 citations
- A Lightweight Type-and-Effect System for Invalidation Safety: Tracking Permanent and Temporary Invalidation with Constraint-Based Subtype InferenceCunyuan Gao, Lionel ParreauxOOPSLA 2025 · 4 citations
- Zero-Overhead Lexical Effect HandlersCong Ma, Zhaoyi Ge, Max Jung, Yizhou ZhangOOPSLA 2025 · 2 citations
- Qualified Types with Boolean AlgebrasEdward Lee, Jonathan Lindegaard Starup, Ondrej Lhoták, Magnus MadsenOOPSLA 2025 · 1 citation
- Virtualizing ContinuationsCong Ma, Jonghyun Jung, Yizhou ZhangPLDI 2026
Builds on7
- Effects as capabilities: effect handlers and lightweight effect polymorphismJonathan Immanuel Brachthäuser, Philipp Schuster, Klaus OstermannOOPSLA 2020 · 62 citations
- Retrofitting effect handlers onto OCamlK. C. Sivaramakrishnan, Stephen Dolan, Leo White, Tom Kelly et al.PLDI 2021 · 56 citations
- Binders by day, labels by night: effect instances via lexically scoped handlersDariusz Biernacki, Maciej Piróg, Piotr Polesiuk, Filip SieczkowskiPOPL 2020 · 46 citations
- Effects, capabilities, and boxes: from scope-based reasoning to type-based reasoning and backJonathan Immanuel Brachthäuser, Philipp Schuster, Edward Lee, Aleksander Boruch-GruszeckiOOPSLA 2022 · 24 citations
- From folklore to fact: comparing implementations of stacks and continuationsKavon Farvardin, John H. ReppyPLDI 2020 · 17 citations
Related papers
- Modal Effect TypesWenhao Tang, Leo White, Stephen Dolan, Daniel Hillerström et al.OOPSLA 2025 · 4 citations
- Efficient compilation of algebraic effect handlersGeorgios Karachalias, Filip Koprivec, Matija Pretnar, Tom SchrijversOOPSLA 2021 · 9 citations
- A typed continuation-passing translation for lexical effect handlersPhilipp Schuster, Jonathan Immanuel Brachthäuser, Marius Müller, Klaus OstermannPLDI 2022 · 10 citations
- Answer Refinement Modification: Refinement Type System for Algebraic Effects and HandlersFuga Kawamata, Hiroshi Unno, Taro Sekiyama, Tachio TerauchiPOPL 2024 · 8 citations
- Handling Higher-Order Effectful Operations with Judgemental Monadic LawsZhixuan Yang, Nicolas WuPOPL 2026
