Affect: An Affine Type and Effect System
Orpheas van Rooij, Robbert Krebbers
Abstract
Effect handlers form a powerful construct that can express complex programming abstractions. They are a generalisation of exception handlers, but allow resumption of the continuation from where the effect was raised. Allowing continuations to be resumed at most once ( one-shot ) or an arbitrary number of times ( multi-shot ) has far-reaching consequences. In addition to performance considerations, multi-shot effects break key rules of reasoning and thus render certain standard transformation/optimisations unsound, especially in languages with mutable references (such as OCaml 5). It is therefore desirable to statically track whether continuations are used in a one-shot or multi-shot discipline, so that a compiler could use this information to efficiently implement effect handlers and to determine what optimizations it may perform. We address this problem by developing a type and effect system–called Affect –which uses affine types to track the usage of continuations. A challenge is to soundly deal with advanced programming features—such as references that store continuations and nested continuations—which are crucial to support challenging examples from the effects literature (such as control inversion and cooperative concurrency ). Another challenge is to support generic type signatures of polymorphic effectful functions. We address these challenges by using and extending Rust's Cell type and Wadler's use types . To prove soundness of Affect we model types and judgements semantically via a logical relation in the Iris separation logic framework in Coq.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 3842e1c8-6975-4198-9b67-5af4566e34bdCited by top-tier papers3
- A Relational Separation Logic for Effect HandlersPaulo Emílio de Vilhena, Simcha van Collem, Ines Wright, Robbert KrebbersPOPL 2026 · 3 citations
- Dynamic Wind for Effect HandlersDavid Voigt, Philipp Schuster, Jonathan Immanuel BrachthäuserOOPSLA 2025
- Handling Exceptions and Effects with Automatic Resource AnalysisEthan Chu, Yiyang Guo, Jan HoffmannOOPSLA 2026
Builds on4
- Effects as capabilities: effect handlers and lightweight effect polymorphismJonathan Immanuel Brachthäuser, Philipp Schuster, Klaus OstermannOOPSLA 2020 · 62 citations
- Retrofitting effect handlers onto OCamlK. C. Sivaramakrishnan, Stephen Dolan, Leo White, Tom Kelly et al.PLDI 2021 · 56 citations
- A separation logic for effect handlersPaulo Emílio de Vilhena, François PottierPOPL 2021 · 24 citations
- Soundly Handling LinearityWenhao Tang, Daniel Hillerström, Sam Lindley, J. Garrett MorrisPOPL 2024 · 8 citations
Related papers
- Answer Refinement Modification: Refinement Type System for Algebraic Effects and HandlersFuga Kawamata, Hiroshi Unno, Taro Sekiyama, Tachio TerauchiPOPL 2024 · 8 citations
- Binders by day, labels by night: effect instances via lexically scoped handlersDariusz Biernacki, Maciej Piróg, Piotr Polesiuk, Filip SieczkowskiPOPL 2020 · 46 citations
- Virtualizing ContinuationsCong Ma, Jonghyun Jung, Yizhou ZhangPLDI 2026
- Modal Effect TypesWenhao Tang, Leo White, Stephen Dolan, Daniel Hillerström et al.OOPSLA 2025 · 4 citations
- A typed continuation-passing translation for lexical effect handlersPhilipp Schuster, Jonathan Immanuel Brachthäuser, Marius Müller, Klaus OstermannPLDI 2022 · 10 citations
