What's in the Box: Ergonomic and Expressive Capture Tracking over Generic Data Structures
Yichen Xu, Oliver Bracevac, Cao Nguyen Pham, Martin Odersky
Abstract
Capturing types in Scala unify static effect and resource tracking with object capabilities, enabling lightweight effect polymorphism with minimal notational overhead. However, their expressiveness has been insufficient for tracking capabilities embedded in generic data structures, preventing them from scaling to the standard collections library -an essential prerequisite for broader adoption. This limitation stems from the inability to name capabilities within the system's notion of box types.
This paper develops System Capless, a new foundation for capturing types that provides the theoretical basis for reach capabilities (rcaps), a novel mechanism for naming "what's in the box". The calculus refines the universal capability notion into a new scheme with existential and universal capture set quantification. Intuitively, rcaps witness existentially quantified capture sets inside the boxes of generic types in a way that does not require exposing existential capture types in the surface language. We have fully mechanized the formal metatheory of System Capless in Lean, including proofs of type soundness and scope safety. System Capless supports the same lightweight notation of capturing types plus rcaps, as certified by a type-preserving translation, and also enables fully optional explicit capture-set quantification to increase expressiveness.
Finally, we present a full reimplementation of capture checking in Scala 3 based on System Capless and migrate the entire Scala collections library and an asynchronous programming library to evaluate its practicality and ergonomics. Our results demonstrate that reach capabilities enable the adoption of capture checking in production code with minimal changes and minimal-to-zero notational overhead in a vast majority of 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.
6 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
- Tracking Borrows with Regular Expressions cites Reachability types: tracking aliasing and separation in higher-order functional programs
- Graph IRs for Impure Higher-Order Languages: Making Aggressive Optimizations Affordable with Precise Effect Dependencies cites Reachability types: tracking aliasing and separation in higher-order functional programs
- Typestate via Revocable Capabilities cites Graph IRs for Impure Higher-Order Languages: Making Aggressive Optimizations Affordable with Precise Effect Dependencies
- Typestate via Revocable Capabilities cites Effects, capabilities, and boxes: from scope-based reasoning to type-based reasoning and back
- Typestate via Revocable Capabilities cites Reachability types: tracking aliasing and separation in higher-order functional programs
- Typestate via Revocable Capabilities cites Escape with Your Self: Sound and Expressive Bidirectional Typing with Avoidance for Reachability Types
- Effects, capabilities, and boxes: from scope-based reasoning to type-based reasoning and back cites Effects as capabilities: effect handlers and lightweight effect polymorphism
- Classifying Capabilities cites Effects as capabilities: effect handlers and lightweight effect polymorphism
- Classifying Capabilities cites Rows and Capabilities as Modal Effects
- Reachability types: tracking aliasing and separation in higher-order functional programs cites Effects as capabilities: effect handlers and lightweight effect polymorphism
- Rows and Capabilities as Modal Effects cites Effects, capabilities, and boxes: from scope-based reasoning to type-based reasoning and back
- Rows and Capabilities as Modal Effects cites Effects as capabilities: effect handlers and lightweight effect polymorphism
- Escape with Your Self: Sound and Expressive Bidirectional Typing with Avoidance for Reachability Types cites Reachability types: tracking aliasing and separation in higher-order functional programs
- Reference Capabilities for Flexible Memory Management cites Effects, capabilities, and boxes: from scope-based reasoning to type-based reasoning and back
Cited by top-tier papers6
- Rows and Capabilities as Modal EffectsWenhao Tang, Sam LindleyPOPL 2026 · 1 citation
- Escape with Your Self: Sound and Expressive Bidirectional Typing with Avoidance for Reachability TypesSonglin Jia, Guannan Wei, Siyuan He, Yuyan Bao et al.PLDI 2026 · 1 citation
- Tracking Borrows with Regular ExpressionsTodd Nowacki, Sam Blackshear, John Mitchell, Shaz Qadeer et al.OOPSLA 2026
- Typestate via Revocable CapabilitiesSonglin Jia, Craig Liu, Siyuan He, Haotian Deng et al.PLDI 2026
- Classifying CapabilitiesCao Nguyen Pham, Oliver Bračevac, Yichen Xu, Yaoyu Zhao et al.OOPSLA 2026
Builds on10
- Effects as capabilities: effect handlers and lightweight effect polymorphismJonathan Immanuel Brachthäuser, Philipp Schuster, Klaus OstermannOOPSLA 2020 · 62 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
- Reachability types: tracking aliasing and separation in higher-order functional programsYuyan Bao, Guannan Wei, Oliver Bracevac, Yuxuan Jiang et al.OOPSLA 2021 · 19 citations
- Reference Capabilities for Flexible Memory ManagementEllen Arvidsson, Elias Castegren, Sylvan Clebsch, Sophia Drossopoulou et al.OOPSLA 2023 · 17 citations
- Graph IRs for Impure Higher-Order Languages: Making Aggressive Optimizations Affordable with Precise Effect DependenciesOliver Bracevac, Guannan Wei, Songlin Jia, Supun Abeysinghe et al.OOPSLA 2023 · 14 citations
Related papers
- Polymorphic Reachability Types: Tracking Freshness, Aliasing, and Separation in Higher-Order Generic ProgramsGuannan Wei, Oliver Bracevac, Songlin Jia, Yuyan Bao et al.POPL 2024 · 12 citations
- Qualifying System F<: Some Terms and Conditions May ApplyEdward Lee, Yaoyu Zhao, Ondrej Lhoták, James You et al.OOPSLA 2024 · 2 citations
- Complete the Cycle: Reachability Types with Expressive Cyclic ReferencesHaotian Deng, Siyuan He, Songlin Jia, Yuyan Bao et al.OOPSLA 2025 · 3 citations
- Degrees of Separation: A Flexible Type System for Safe ConcurrencyYichen Xu, Aleksander Boruch-Gruszecki, Martin OderskyOOPSLA 2024 · 6 citations
- Type-level programming with match typesOlivier Blanvillain, Jonathan Immanuel Brachthäuser, Maxime Kjaer, Martin OderskyPOPL 2022 · 10 citations
