Lune

POPL2024Top-tier venue

Soundly Handling Linearity

Wenhao Tang, Daniel Hillerström, Sam Lindley, J. Garrett Morris

Abstract

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.

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.

4 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Modal Effect Types cites Retrofitting effect handlers onto OCaml
  • Modal Effect Types cites Continuing WebAssembly with Effect Handlers
  • Modal Effect Types cites Effects as capabilities: effect handlers and lightweight effect polymorphism
  • Modal Effect Types cites Binders by day, labels by night: effect instances via lexically scoped handlers
  • Dynamic Wind for Effect Handlers cites Retrofitting effect handlers onto OCaml
  • Dynamic Wind for Effect Handlers cites Affect: An Affine Type and Effect System
  • Dynamic Wind for Effect Handlers cites Continuing WebAssembly with Effect Handlers
  • Dynamic Wind for Effect Handlers cites Effects as capabilities: effect handlers and lightweight effect polymorphism
  • Retrofitting effect handlers onto OCaml cites Binders by day, labels by night: effect instances via lexically scoped handlers
  • Affect: An Affine Type and Effect System cites Retrofitting effect handlers onto OCaml
  • Affect: An Affine Type and Effect System cites Effects as capabilities: effect handlers and lightweight effect polymorphism
  • Continuing WebAssembly with Effect Handlers cites Retrofitting effect handlers onto OCaml
  • Continuing WebAssembly with Effect Handlers cites High-level effect handlers in C++
  • Effects as capabilities: effect handlers and lightweight effect polymorphism cites Binders by day, labels by night: effect instances via lexically scoped handlers
  • High-level effect handlers in C++ cites Retrofitting effect handlers onto OCaml
  • High-level effect handlers in C++ cites Binders by day, labels by night: effect instances via lexically scoped handlers
  • A Relational Separation Logic for Effect Handlers cites Modal Effect Types
  • A Relational Separation Logic for Effect Handlers cites Affect: An Affine Type and Effect System
  • A Relational Separation Logic for Effect Handlers cites Binders by day, labels by night: effect instances via lexically scoped handlers
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers4

  1. Affect: An Affine Type and Effect SystemOrpheas van Rooij, Robbert KrebbersPOPL 2025 · 7 citations
  2. Modal Effect TypesWenhao Tang, Leo White, Stephen Dolan, Daniel Hillerström et al.OOPSLA 2025 · 4 citations
  3. A Relational Separation Logic for Effect HandlersPaulo Emílio de Vilhena, Simcha van Collem, Ines Wright, Robbert KrebbersPOPL 2026 · 3 citations
  4. Dynamic Wind for Effect HandlersDavid Voigt, Philipp Schuster, Jonathan Immanuel BrachthäuserOOPSLA 2025

Builds on6

  1. Effects as capabilities: effect handlers and lightweight effect polymorphismJonathan Immanuel Brachthäuser, Philipp Schuster, Klaus OstermannOOPSLA 2020 · 62 citations
  2. Retrofitting effect handlers onto OCamlK. C. Sivaramakrishnan, Stephen Dolan, Leo White, Tom Kelly et al.PLDI 2021 · 56 citations
  3. Binders by day, labels by night: effect instances via lexically scoped handlersDariusz Biernacki, Maciej Piróg, Piotr Polesiuk, Filip SieczkowskiPOPL 2020 · 46 citations
  4. Continuing WebAssembly with Effect HandlersLuna Phipps-Costin, Andreas Rossberg, Arjun Guha, Daan Leijen et al.OOPSLA 2023 · 20 citations
  5. High-level effect handlers in C++Dan R. Ghica, Sam Lindley, Marcos Maroñas Bravo, Maciej PirógOOPSLA 2022 · 14 citations

Related papers

  1. A typed continuation-passing translation for lexical effect handlersPhilipp Schuster, Jonathan Immanuel Brachthäuser, Marius Müller, Klaus OstermannPLDI 2022 · 10 citations
  2. Qualified Types with Boolean AlgebrasEdward Lee, Jonathan Lindegaard Starup, Ondrej Lhoták, Magnus MadsenOOPSLA 2025 · 1 citation
  3. Virtualizing ContinuationsCong Ma, Jonghyun Jung, Yizhou ZhangPLDI 2026
  4. Handling bidirectional control flowYizhou Zhang, Guido Salvaneschi, Andrew C. MyersOOPSLA 2020 · 12 citations
  5. Rows and Capabilities as Modal EffectsWenhao Tang, Sam LindleyPOPL 2026 · 1 citation
Dusk over the sea between two cliffs drawn in fine vertical lines