🤖 AI Summary
This work addresses the tension between algebraic effects and region-based memory management: non-local control flow induced by algebraic effects disrupts the stack-like scoping assumed by regions, while multi-shot effect handlers further violate the critical invariant that a region is exited at most once. To reconcile these features, the paper introduces Yarrow, a novel language that unifies algebraic effects with region-based memory management for the first time. It also develops Yarrow Logic (YL), enabling safe and modular reasoning about regions under both single-shot and multi-shot effect handlers. Building on an operational semantics with region refinement inspired by the OCaml runtime, the authors formalize both semantics and logic within the Iris separation logic framework in Coq, and successfully verify representative examples—including checkpointing, asynchronous computation, and LIFO structures—where all memory is region-allocated without garbage collection.
📝 Abstract
We present a new ML-like programming language Yarrow with algebraic effects and region-based memory management. Reconciling these programming language features into one language is challenging: the non-local control flow of algebraic effects break the stack discipline of function calls and returns that region-based memory management relies on, and multi-shot effect handlers break the invariant that regions can be exited at most once. We present a program logic, called Yarrow Logic (YL), that supports safe and modular reasoning about regions in the presence of one-shot and multi-shot effect handlers. We prove the logic sound w.r.t. the operational semantics of Yarrow which is inspired by the runtime of OCaml but refined for regions. We use YL to prove correctness of a number of case studies with algebraic effects, including checkpointing, asynchronous computation and a LIFO data structure implementation. Since all memory locations used in these case studies are allocated in regions, these case studies avoid using the less efficient garbage collected heap memory. We have formalized Yarrow's operational semantics, the Yarrow program logic, and all our case studies using the Iris separation logic framework on top of the Rocq Prover.