Incremental Bidirectional Typing via Order Maintenance
Thomas Porter, Marisa Kirisame, Ivan Wei, Pavel Panchekha, Cyrus Omar
Abstract
Live programming environments provide various semantic services, including type checking and evaluation, continuously as the user is editing the program. The live paradigm promises to improve the developer experience, but liveness is an implementation challenge, particularly when working with large programs. This paper specifies and efficiently implements a system that is able to incrementally update type information for a live program in response to fine-grained program edits. This information includes type error marks and information about the expected and actual type of every expression. The system is specified type-theoretically as a small-step dynamics that propagates updates through the marked and annotated program. Most updates flow according to a base bidirectional type system. Additional pointers are maintained to connect bound variables to their binding locations, with type updates traversing these pointers directly. Order maintenance data structures are employed to efficiently maintain these pointers and to prioritize the order of update propagation. We prove this system is equivalent to naive reanalysis in the Agda theorem prover, along with other important metatheoretic properties. We then provide an efficient OCaml implementation, detailing a number of impactful optimizations. We evaluate this implementation’s performance with a large stress-test and find that it is able to achieve multiple orders of magnitude speed-up compared to from-scratch reanalysis.
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 81e24d03-912e-4fd1-9f1a-80eb85be7bb5Cited by top-tier papers1
Ask how each one uses itBuilds on4
- A systematic approach to deriving incremental type checkersAndré Pacak, Sebastian Erdweg, Tamás SzabóOOPSLA 2020 · 16 citations
- Total Type Error Localization and Recovery with HolesEric Zhao, Raef Maroof, Anand Dukkipati, Andrew Blinn et al.POPL 2024 · 15 citations
- Pantograph: A Fluid and Typed Structure EditorJacob Prinz, Henry Blanchette, Leonidas LampropoulosPOPL 2025 · 1 citation
- Spineless Traversal for Layout InvalidationMarisa Kirisame, Tiezhi Wang, Pavel PanchekhaPLDI 2025
Related papers
- Live Pattern Matching with Typed HolesYongwei Yuan, Scott Guest, Eric Griffis, Hannah Potter et al.OOPSLA 2023 · 9 citations
- Type error feedback via analytic program repairGeorgios Sakkas, Madeline Endres, Benjamin Cosman, Westley Weimer et al.PLDI 2020 · 24 citations
- Answer Refinement Modification: Refinement Type System for Algebraic Effects and HandlersFuga Kawamata, Hiroshi Unno, Taro Sekiyama, Tachio TerauchiPOPL 2024 · 8 citations
- Type Inference LogicsDenis Carnier, François Pottier, Steven KeuchelOOPSLA 2024 · 3 citations
- Filling typed holes with live GUIsCyrus Omar, David Moon, Andrew Blinn, Ian Voysey et al.PLDI 2021 · 35 citations
