Rows and Capabilities as Modal Effects
Wenhao Tang, Sam Lindley
TL;DR
The paper tackles the challenge of comparing and combining diverse effect systems rooted in rows and capabilities. It introduces Met(X), a modal, System F-style core that decouples effect tracking from functions, parameterized by an abstract effect structure X. Through macro-encodings, it shows that both row-based (e.g., F^ε) and capability-based (e.g., Effekt/System C) systems can be faithfully represented in Met(X), preserving typing and semantics and enabling direct comparison of their tracking mechanisms. The contributions include a formal core calculus, modality-based extensions (local labels and modality-parameterised handlers), and detailed encodings of concrete systems with proofs of soundness. Together, these results offer a uniform intermediate representation for designing, optimizing, and extending effect systems across language paradigms, with practical guidance for language designers.
Abstract
Effect handlers allow programmers to model and compose computational effects modularly. Effect systems statically guarantee that all effects are handled. Several recent practical effect systems are based on either row polymorphism or capabilities. However, there remains a gap in understanding the precise relationship between effect systems with such disparate foundations. The main difficulty is that in both row-based and capability-based systems, effect tracking is typically entangled with other features such as functions. We propose a uniform framework for encoding, analysing, and comparing effect systems. Our framework exploits and generalises modal effect types, a recent novel effect system which decouples effect tracking from functions via modalities. Modalities offer fine-grained control over when and how effects are tracked, enabling us to express different strategies for effect tracking. We give encodings as macro translations from existing row-based and capability-based effect systems into our framework and show that these encodings preserve types and semantics. Our encodings reveal the essence of effect tracking mechanisms in different effect systems, enable a direct analysis on their differences, and provide practical insights on language design.
