Soundly Handling Linearity
Wenhao Tang, Daniel Hillerström, Sam Lindley, J. Garrett Morris
摘要
We propose a novel approach to soundly combining linear types with multi-shot effect handlers. Linear type systems statically ensure that resources such as file handles and communication channels are used exactly once. Effect handlers provide a rich modular programming abstraction for implementing features ranging from exceptions to concurrency to backtracking. Whereas conventional linear type systems bake in the assumption that continuations are invoked exactly once, effect handlers allow continuations to be discarded (e.g. for exceptions) or invoked more than once (e.g. for backtracking). This mismatch leads to soundness bugs in existing systems such as the programming language Links , which combines linearity (for session types) with effect handlers. We introduce control-flow linearity as a means to ensure that continuations are used in accordance with the linearity of any resources they capture, ruling out such soundness bugs. We formalise the notion of control-flow linearity in a System F-style core calculus F eff ∘ equipped with linear types, an effect type system, and effect handlers. We define a linearity-aware semantics in order to formally prove that F eff ∘ preserves the integrity of linear values in the sense that no linear value is discarded or duplicated. In order to show that control-flow linearity can be made practical, we adapt Links based on the design of F eff ∘ , in doing so fixing a long-standing soundness bug. Finally, to better expose the potential of control-flow linearity, we define an ML-style core calculus Q eff ∘ , based on qualified types, which requires no programmer provided annotations, and instead relies entirely on type inference to infer control-flow linearity. Both linearity and effects are captured by qualified types. Q eff ∘ overcomes a number of practical limitations of F eff ∘ , supporting abstraction over linearity, linearity dependencies between type variables, and a much more fine-grained notion of control-flow linearity.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 4 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Modal Effect Types 引用了 Retrofitting effect handlers onto OCaml
- Modal Effect Types 引用了 Continuing WebAssembly with Effect Handlers
- Modal Effect Types 引用了 Effects as capabilities: effect handlers and lightweight effect polymorphism
- Modal Effect Types 引用了 Binders by day, labels by night: effect instances via lexically scoped handlers
- Dynamic Wind for Effect Handlers 引用了 Retrofitting effect handlers onto OCaml
- Dynamic Wind for Effect Handlers 引用了 Affect: An Affine Type and Effect System
- Dynamic Wind for Effect Handlers 引用了 Continuing WebAssembly with Effect Handlers
- Dynamic Wind for Effect Handlers 引用了 Effects as capabilities: effect handlers and lightweight effect polymorphism
- Retrofitting effect handlers onto OCaml 引用了 Binders by day, labels by night: effect instances via lexically scoped handlers
- Affect: An Affine Type and Effect System 引用了 Retrofitting effect handlers onto OCaml
- Affect: An Affine Type and Effect System 引用了 Effects as capabilities: effect handlers and lightweight effect polymorphism
- Continuing WebAssembly with Effect Handlers 引用了 Retrofitting effect handlers onto OCaml
- Continuing WebAssembly with Effect Handlers 引用了 High-level effect handlers in C++
- Effects as capabilities: effect handlers and lightweight effect polymorphism 引用了 Binders by day, labels by night: effect instances via lexically scoped handlers
- High-level effect handlers in C++ 引用了 Retrofitting effect handlers onto OCaml
- High-level effect handlers in C++ 引用了 Binders by day, labels by night: effect instances via lexically scoped handlers
- A Relational Separation Logic for Effect Handlers 引用了 Modal Effect Types
- A Relational Separation Logic for Effect Handlers 引用了 Affect: An Affine Type and Effect System
- A Relational Separation Logic for Effect Handlers 引用了 Binders by day, labels by night: effect instances via lexically scoped handlers
引用它的顶会 Paper4
- Affect: An Affine Type and Effect SystemOrpheas van Rooij, Robbert KrebbersPOPL 2025 · 7 次引用
- Modal Effect TypesWenhao Tang, Leo White, Stephen Dolan, Daniel Hillerström 等OOPSLA 2025 · 4 次引用
- A Relational Separation Logic for Effect HandlersPaulo Emílio de Vilhena, Simcha van Collem, Ines Wright, Robbert KrebbersPOPL 2026 · 3 次引用
- Dynamic Wind for Effect HandlersDavid Voigt, Philipp Schuster, Jonathan Immanuel BrachthäuserOOPSLA 2025
它引用的 Paper6
- Effects as capabilities: effect handlers and lightweight effect polymorphismJonathan Immanuel Brachthäuser, Philipp Schuster, Klaus OstermannOOPSLA 2020 · 62 次引用
- Retrofitting effect handlers onto OCamlK. C. Sivaramakrishnan, Stephen Dolan, Leo White, Tom Kelly 等PLDI 2021 · 56 次引用
- Binders by day, labels by night: effect instances via lexically scoped handlersDariusz Biernacki, Maciej Piróg, Piotr Polesiuk, Filip SieczkowskiPOPL 2020 · 46 次引用
- Continuing WebAssembly with Effect HandlersLuna Phipps-Costin, Andreas Rossberg, Arjun Guha, Daan Leijen 等OOPSLA 2023 · 20 次引用
- High-level effect handlers in C++Dan R. Ghica, Sam Lindley, Marcos Maroñas Bravo, Maciej PirógOOPSLA 2022 · 14 次引用
相关 Paper
- A typed continuation-passing translation for lexical effect handlersPhilipp Schuster, Jonathan Immanuel Brachthäuser, Marius Müller, Klaus OstermannPLDI 2022 · 10 次引用
- Qualified Types with Boolean AlgebrasEdward Lee, Jonathan Lindegaard Starup, Ondrej Lhoták, Magnus MadsenOOPSLA 2025 · 1 次引用
- Virtualizing ContinuationsCong Ma, Jonghyun Jung, Yizhou ZhangPLDI 2026
- Handling bidirectional control flowYizhou Zhang, Guido Salvaneschi, Andrew C. MyersOOPSLA 2020 · 12 次引用
- Rows and Capabilities as Modal EffectsWenhao Tang, Sam LindleyPOPL 2026 · 1 次引用
