Classifying Capabilities
Cao Nguyen Pham, Oliver Bračevac, Yichen Xu, Yaoyu Zhao, Martin Odersky
Key points
From the paper's conclusion- We introduce capability classifiers : a tree-structured, user-extensible hierarchy of tags that classify capabilities by their semantic role.
Abstract
Capture checking in Scala 3 enables lightweight and practical effect and resource tracking by recording capabilities in types. However, the system offers no way to reason about kinds of capabilities. Natural constraints such as “retaining only the control-flow capabilities of this closure” or “excluding all thread-local capabilities from this argument” become inexpressible. Both arise in the Scala 3 standard library: Try re-throws caught exceptions, so it retains only the control-flow capabilities of its body, and Future must not capture thread-local resources. The inability to state these constraints has kept parts of the library outside capture checking. We introduce capability classifiers : a tree-structured, user-extensible hierarchy of tags that classify capabilities by their semantic role. Projections filter capture sets by classifier, supporting both inclusion (c.only[C]) and exclusion (c.except[C]). The tree structure enables decidable disjointness reasoning: classifiers on separate branches are guaranteed to be disjoint regardless of unknown extensions elsewhere in the hierarchy. We formalize classifiers as an extension of System Capless, a core calculus for capture checking, introducing a classifier kind algebra based on intersection, union, and subtraction of classifier subtrees. We extend the operational semantics to model exception interception and establish type safety, effect safety, and handler coverage via a big-step proof, fully mechanized in Lean 4. Classifiers are implemented in the Scala 3 capture checker, and we demonstrate their use on standard library types and real-world effect exclusion patterns.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- A Relational Separation Logic for Effect HandlersProceedings of the ACM on Programming Languages · 2026
- Recursive Formation and First-Class Reuse of Compositional CapabilitiesarXiv · 2026
- Context Types: Bunched Modalities for Unifying Safety and ReachabilityarXiv · 2026
- First-Class Refinement Types for ScalaProceedings of the ACM on Programming Languages · 2026
- Type, Ability, and Effect Systems: Perspectives on Purity, Semantics, and ExpressivenessProceedings of the ACM on Programming Languages · 2026
- Compiling Environment Classifiers to Contextual Modal TypesarXiv · 2026