paperbot · PL 论文追踪

全部论文 待读 收藏

P2 An efficient algorithm for type-safe structural diffing

一种高效的类型安全结构化差异比较算法
ICFP 3(ICFP)2019匹配度 3/10 · 该论文属于编程语言与开发者工具方向,研究泛型结构化 diff 与 AST 补丁合并,和用户核心关注的静态分析、LLM/Agent、浮点程序分析、贝叶斯程序分析均无直接关系。它至多对 PL 工具实现有间接参考价值,不属于当前研究画像的核心。引用 4 inbox
Victor Cacciari Miraldo, Wouter Swierstra
crossref: 2026-09-10

AI 速览

一句话:提出一种线性时间、类型安全的数据类型泛型结构化 diff 算法,最大化共享并提升补丁自动合并率。

版本控制中广泛使用的 UNIX diff 按行比较文件,忽略源码或数据的结构,因此难以对抽象语法树等结构化数据做精确差异与自动合并。本文提出一种数据类型泛型(datatype-generic)的结构化 diff 算法,适用于任意代数数据类型的值:它在保证类型安全的同时最大化源树与目标树之间的共享,且运行时间为线性。作者将该算法实例化到 Lua 抽象语法树,并通过挖掘 GitHub 仓库提交历史进行评估。结果表明,由此生成的补丁常常可以自动合并,即使在现有技术失败的情况下也是如此。

问题
传统 UNIX diff 按行比较文件,忽略源码或数据的结构信息,难以支持抽象语法树等结构化数据的差异计算与自动合并。
方法
提出一种面向任意代数数据类型的 datatype-generic 结构化 diff 算法,在类型安全的前提下最大化源树与目标树的共享,并保持线性时间复杂度。
评估
将算法实例化到 Lua 抽象语法树,并挖掘 GitHub 仓库提交历史;结果显示生成的补丁在现有技术失败时仍常可自动合并。
原文摘要(Abstract)

Effectively computing the difference between two version of a source file has become an indispensable part of software development. The de facto standard tool used by most version control systems is the UNIX diff utility, that compares two files on a line-by-line basis without any regard for the structure of the data stored in these files. This paper presents an alternative datatype generic algorithm for computing the difference between two values of any algebraic datatype. This algorithm maximizes sharing between the source and target trees, while still running in linear time. Finally, this paper demonstrates that by instantiating this algorithm to the Lua abstract syntax tree and mining the commit history of repositories found on GitHub, the resulting patches can often be merged automatically, even when existing technology has failed.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot610,
  title = {An efficient algorithm for type-safe structural diffing},
  author = {Victor Cacciari Miraldo and Wouter Swierstra},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {3},
  number = {ICFP},
  year = {2019},
  doi = {10.1145/3341717}
}