paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Generic deriving of generic traversals

泛型遍历的泛型派生
ICFP 2(ICFP)2018匹配度 2/10 · 该论文属于函数式编程中的泛型遍历与 lens 派生技术,虽与程序语言/编译优化相关,但未涉及静态分析、机器学习系统、Agentic 程序、LLM 与程序分析交叉、浮点程序分析或贝叶斯程序分析等核心方向。引用 7 inbox
Csongor Kiss, Matthew Pickering, Nicolas Wu
crossref: 2026-09-10

AI 速览

一句话:提出结合 lens 与 traversal 的泛型派生库,可自动生成高效的数据结构查询与修改遍历。

函数式编程中,traversal 与 lens 是处理递归数据结构的常用模式。已有许多库能根据数据类型的泛型结构自动派生 traversal,但如何在保持表达力的同时生成高效代码仍具挑战。本文结合 lens 与 traversal,提出一种泛型派生方法:利用数据类型的泛型形状生成通用抽象,再通过编译器内联与特化将其消除。由此得到的库在查询和修改复杂数据结构方面具有前所未有的表达力与灵活性,且生成的代码性能可与手写优化版本相当。

问题
如何自动为递归数据结构提供表达力强、灵活且高效的 traversal 与 lens 支持,是函数式编程中的问题。
方法
利用数据类型的泛型结构派生 lens/traversal 抽象,并借助编译器的内联与特化消除泛型抽象。
评估
论文以库的形式展示其对复杂数据结构的查询与修改能力,并论证生成代码可达到与手写优化版本相当的性能。
原文摘要(Abstract)

Functional programmers have an established tradition of using traversals as a design pattern to work with recursive data structures. The technique is so prolific that a whole host of libraries have been designed to help in the task of automatically providing traversals by analysing the generic structure of data types. More recently, lenses have entered the functional scene and have proved themselves to be a simple and versatile mechanism for working with product types. They make it easy to focus on the salient parts of a data structure in a composable and reusable manner. This paper uses the combination of lenses and traversals to give rise to a library with unprecedented expressivity and flexibility for querying and modifying complex data structures. Furthermore, since lenses and traversals are based on the generic shape of data, this information is used to generate code that is as efficient as hand-optimised versions. The technique leverages the structure of data to produce generic abstractions that are then eliminated by the standard workhorses of modern functional compilers: inlining and specialisation.

链接与引用

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

BibTeX
@article{paperbot271,
  title = {Generic deriving of generic traversals},
  author = {Csongor Kiss and Matthew Pickering and Nicolas Wu},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {2},
  number = {ICFP},
  year = {2018},
  doi = {10.1145/3236780}
}