Handling Bidirectional Control Flow: Technical Report
Yizhou Zhang, Guido Salvaneschi, Andrew C. Myers

TL;DR
This paper introduces bidirectional algebraic effects, a new abstraction for managing complex, bidirectional control flow in programming languages, unifying effect handling with object-oriented programming and ensuring type safety.
Contribution
It formalizes bidirectional effects, develops a core language with semantics and proofs, and demonstrates efficient implementation, advancing control flow management in effectful programming.
Findings
Bidirectional effects enable natural control transfer patterns.
The core language is proven type-safe and abstraction-safe.
Preliminary experiments show efficient implementation.
Abstract
Pressed by the difficulty of writing asynchronous, event-driven code, mainstream languages have recently been building in support for a variety of advanced control-flow features. Meanwhile, experimental language designs have suggested effect handlers as a unifying solution to programmer-defined control effects, subsuming exceptions, generators, and async--await. Despite these trends, complex control flow---in particular, control flow exhibiting a bidirectional pattern---remains challenging to manage. We introduce bidirectional algebraic effects, a new programming abstraction that supports bidirectional control transfer in a more natural way. Handlers of bidirectional effects can raise further effects to transfer control back to the site where the initiating effect was raised, and can use themselves to handle their own effects. We present applications of this expressive power, which…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsLogic, programming, and type systems · Formal Methods in Verification · Security and Verification in Computing
