Lexical Effect Handlers, Directly
Cong Ma, Zhaoyi Ge, Edward Lee, Yizhou Zhang
Abstract
Lexically scoping effect handlers is a language-design idea that equips algebraic effects with a modular semantics: it enables local-reasoning principles without giving up on the control-flow expressiveness that makes effect handlers powerful. However, we observe that existing implementations risk incurring costs akin to the run-time search for dynamically scoped handlers. This paper presents a compilation strategy for lexical effect handlers, adhering to the lexical scoping principle and targeting a language with low-level control over stack layout. Key aspects of this approach are formalized and proven correct. We embody the ideas in a language called L exa : the L exa compiler translates high-level effect handling to low-level stack switching. We evaluate the L exa compiler on a set of benchmarks; the results suggest that it generates efficient code, reducing running-time complexity from quadratic to linear in some cases.
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.
5 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
- Retrofitting effect handlers onto OCaml cites Binders by day, labels by night: effect instances via lexically scoped handlers
- 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 Retrofitting effect handlers onto OCaml
- Zero-Overhead Lexical Effect Handlers cites Continuing WebAssembly with Effect Handlers
- 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
- Classifying Capabilities cites Effects as capabilities: effect handlers and lightweight effect polymorphism
- 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 Binders by day, labels by night: effect instances via lexically scoped handlers
- Continuing WebAssembly with Effect Handlers cites Retrofitting effect handlers onto OCaml
- Effects as capabilities: effect handlers and lightweight effect polymorphism cites Binders by day, labels by night: effect instances via lexically scoped handlers
- Tracing Just-in-Time Compilation for Effects and Handlers cites Retrofitting effect handlers onto OCaml
- Tracing Just-in-Time Compilation for Effects and Handlers cites Continuing WebAssembly with Effect Handlers
- Tracing Just-in-Time Compilation for Effects and Handlers cites Effects as capabilities: effect handlers and lightweight effect polymorphism
- Tracing Just-in-Time Compilation for Effects and Handlers cites Binders by day, labels by night: effect instances via lexically scoped handlers
Cited by top-tier papers5
- 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
- Classifying CapabilitiesCao Nguyen Pham, Oliver Bračevac, Yichen Xu, Yaoyu Zhao et al.OOPSLA 2026
- Virtualizing ContinuationsCong Ma, Jonghyun Jung, Yizhou ZhangPLDI 2026
- Tracing Just-in-Time Compilation for Effects and HandlersMarcial Gaißert, Carl Friedrich Bolz-Tereick, Jonathan Immanuel BrachthäuserOOPSLA 2025
Builds on10
- 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
- Continuing WebAssembly with Effect HandlersLuna Phipps-Costin, Andreas Rossberg, Arjun Guha, Daan Leijen et al.OOPSLA 2023 · 20 citations
Related papers
- Dynamic Wind for Effect HandlersDavid Voigt, Philipp Schuster, Jonathan Immanuel BrachthäuserOOPSLA 2025
- 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
- First-class names for effect handlersNingning Xie, Youyou Cong, Kazuki Ikemori, Daan LeijenOOPSLA 2022 · 11 citations
- Hefty Algebras: Modular Elaboration of Higher-Order Algebraic EffectsCasper Bach Poulsen, Cas van der RestPOPL 2023 · 9 citations
