Cambria: Resource Abstraction for Parametrized Algebraic Effects and Handlers
Jack Liell-Cock, Sam Staton
Abstract
The algebraic effects and handlers paradigm separates the concerns of the interface and implementation of computational effects in programming languages. We present Cambria, a language that extends this framework to the parametrized setting. Effect signatures may use abstract parameter types that are instantiated by the handler along with the operation implementations. Parameters abstract over resources, such as memory locations or thread IDs, permitting algebraic effects to encode dynamic allocation. They are first-class in the type system but erased at runtime, requiring no coercions or type-directed reduction. We prove parametricity via a step-indexed logical relation, formalizing the abstraction guarantee provided by parametrized handlers. We also establish type safety and classify the annotations needed for completeness of the type inference algorithm. We demonstrate Cambria's practicality with a working implementation and provide examples including local state, Pólya's urn, and concurrent thread management. The last is a parametrized effect whose abstract thread IDs are shared between concurrent computations, going beyond standard instances. Cambria is the first calculus with user-defined resource-allocating effects that guarantees, via parametricity, that client code cannot depend on how a handler represents its resources.
Create a lesson
Related papers
Beyond Locks and Thread IDs: Static Data Race Detection Off The Beaten Path (Extended Version)
Daniel Bund, Julian Erhard, Michael Petter et al.
Separating Parsing Expression Grammars using Cell-Probe Lower Bounds
Jungyeom Kim, Jihyeok Park
Fine-grained Causal Reversibility for Asynchronous Channel-based Programming
Shunya Oguchi, Shoji Yuen, Nobuko Yoshida et al.
URIUM: A Programming Language for a Practical Open Course on Compiler Design
Francisco J. Moreno Velo, Almudena García Jurado-Centurión
Tacet: A Language and Type System for Automatic Statistical Validity Accounting
Chiké Abuah
You may implement this later: Cofunctors as partial implementations
Vincent Wang-Maścianica