paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Programming with Composable Recursive Patterns and Transformations

使用可组合递归模式与变换进行编程
OOPSLA 10(OOPSLA2)2026匹配度 3/10 · 论文属于编程语言设计与类型系统,研究递归模式与变换的线性时间识别与类型安全转换,与用户核心方向 PL 与 AI/LLM 的交叉、机器学习系统/Agent 静态分析、浮点或贝叶斯程序分析均无直接关联;仅在程序变换与类型系统理论层面有间接相关性。引用 0 inbox
Luyu Cheng, Florent Ferrari, Michael D. Adams, Lionel Parreaux
crossref: 2026-10-02

AI 速览

一句话:提出 CRPT:可组合递归模式与变换,将递归类型定义用于无回溯的线性时间识别与变换,并给出类型系统与实现。

传统模式匹配和直接递归函数在歧义(非确定性)数据处理中难以避免回溯,常导致代码复杂、模块性差。论文提出可组合递归模式与变换(CRPT),其行为类似结构类型语言中的递归类型定义,可无缝组合以进行类型检查,同时具有运行时语义:被编译为无回溯代码,在输入线性时间、模式多项式时间内识别并变换数据。CRPT 既可作为数据模式验证结构化 JSON 等输入,也能类型安全地变换数据。作者形式化了 CRPT 的动态语义、静态类型系统及其到高效代码的翻译,并在 MLscript 中实现,与若干已有方法对比评估。

问题
在歧义或非确定性的数据处理中,传统模式匹配与直接递归函数难以兼顾代码清晰性、模块化与无回溯的高效执行。
方法
提出 CRPT 这一语言特性,形式化其动态语义、静态类型系统以及到无回溯线性时间代码的翻译,并在 MLscript 中实现。
评估
在多个示例上与已有可比方法进行对比,并实现于 MLscript 以验证其实用性。
原文摘要(Abstract)

Data processing using traditional pattern matching syntax and direct recursive functions is straightforward to write but becomes awkward in ambiguous (i.e., nondeterministic) cases: when programmers wish to avoid backtracking, they often end up having to write complicated code that sacrifices clarity and modularity. However, when the tree language being matched is regular, better solutions are possible. This paper presents composable recursive patterns and transformations (CRPTs), a new programming language feature designed to tackle this problem. CRPTs resemble and act like recursive type definitions in a structurally-typed language, which can be composed seamlessly to type check programs, but they also have a runtime component: they are compiled into backtracking-free code that recognizes and transforms their input in linear time. They serve both to validate existing data—for example, when checking structured JSON input against a CRPT that acts as a data schema—and to transform data in a type-safe and efficient manner. We formalize the dynamic semantics of CRPTs, a static type system for them, and a translation into efficient code that executes in time linear in the size of the input and polynomial in the size of the pattern. We also demonstrate the practicality of CRPTs with an implementation in the MLscript programming language, which we evaluate against comparable existing approaches on several examples.

链接与引用

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

BibTeX
@article{paperbot12082,
  title = {Programming with Composable Recursive Patterns and Transformations},
  author = {Luyu Cheng and Florent Ferrari and Michael D. Adams and Lionel Parreaux},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {10},
  number = {OOPSLA2},
  year = {2026},
  doi = {10.1145/3839500}
}