arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2504.08946cs.PL
收藏

通过顺序维护实现增量双向类型推导

Incremental Bidirectional Typing via Order Maintenance

Thomas J. Porter, Marisa Kirisame, Ivan Wei, Pavel Panchekha, Cyrus Omar

AI总结:

本文提出一种基于顺序维护数据结构的增量双向类型推导系统,通过指针连接绑定变量与绑定位置并优先化更新传播,在 Agda 中证明其等价于朴素重分析,并在 OCaml 实现中取得 275.96 倍加速。

摘要:

实时编程环境在用户编辑程序的过程中持续提供各种语义服务,包括类型检查和求值。实时范式有望改善开发者体验,但实时性在实现上是一项挑战,尤其是在处理大型程序时。本文规定并高效实现了一个系统,该系统能够针对细粒度程序编辑增量更新实时程序的类型信息。这些信息包括类型错误标记以及每个表达式上的期望类型和实际类型信息。该系统在类型论上被规定为一种小步动态语义,通过带标记和带注解的程序传播更新。大多数更新按照基础的双向类型系统流动。系统维护额外的指针,将绑定变量连接到其绑定位置,编辑操作直接沿着这些指针进行遍历。采用顺序维护数据结构来高效维护这些指针,并对更新传播的顺序进行优先级排序。我们在 Agda 定理证明器中证明了该系统等价于朴素重新分析,并证明了其他重要的元理论性质。随后我们在 OCaml 中高效实现了该系统,详细说明了许多有影响力的优化措施。我们通过大规模压力测试评估了该实现的性能,发现与从头重新分析相比,它能够实现 275.96$\ imes$ 的显著加速。

英文摘要:

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 the 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 on 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 edits 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 re-analysis in the Agda theorem prover, along with other important metatheoretic properties. We then implement it efficiently in OCaml, 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 dramatic speed-ups of 275.96$\times$ compared to from-scratch reanalysis.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑