paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Practical generic programming over a universe of native datatypes

在原生数据类型全集上的实用泛型编程
ICFP 6(ICFP)2022匹配度 1/10 · 该论文研究 Agda 中的数据类型泛型编程库,属于纯函数式编程/类型系统方向,与用户关注的 PL 与 AI 交叉、浮点程序分析、贝叶斯程序分析及 LLM/Agent 改进静态分析等核心问题均无直接关联。引用 3 inbox
Lucas Escot, Jesper Cockx
crossref: 2026-09-10

AI 速览

一句话:为 Agda 设计了一个安全易用的数据类型泛型编程库:泛型构造是普通 Agda 函数,可一行特化到原生数据类型。

数据类型泛型编程让同一构造可复用于大量数据类型,在依赖类型语言中还能构造泛型证明,但现有接口要么难以使用,要么所支持的数据类型范围有限。本文在 Agda 中设计了一个安全且易用的数据类型泛型编程库:其核心是一个覆盖广泛数据类型的 universe,泛型构造仍是普通的 Agda 函数,却可以通过一行代码特化到原生 Agda 数据类型;库还提供可复用的构建块,使库设计者能够自行定义新的泛型构造。作者以库实现与示例说明了该设计在可用性和覆盖范围上的改进,从而在依赖类型设定下兼顾安全性与实用性。

问题
依赖类型语言中的数据类型泛型编程接口要么过于难用,要么能处理的数据类型范围有限,导致泛型构造与泛型证明难以真正复用。
方法
在 Agda 中设计一个覆盖广泛数据类型的 universe,使泛型构造就是普通 Agda 函数并可一行特化到原生 Agda 数据类型,同时提供可组合的构建块供库设计者定义自己的泛型构造。
评估
以 Agda 库的形式实现该设计,并通过若干用例展示泛型构造可简洁地特化到原生数据类型以及库设计者对构建块的复用。摘要未给出定量基准评估。
原文摘要(Abstract)

Datatype-generic programming makes it possible to define a construction once and apply it to a large class of datatypes. It is often used to avoid code duplication in languages that encourage the definition of custom datatypes, in particular state-of-the-art dependently typed languages where one can have many variants of the same datatype with different type-level invariants. In addition to giving access to familiar programming constructions for free, datatype-generic programming in the dependently typed setting also allows for the construction of generic proofs. However, the current interfaces available for this purpose are needlessly hard to use or are limited in the range of datatypes they handle. In this paper, we describe the design of a library for safe and user-friendly datatype-generic programming in the Agda language. Generic constructions in our library are regular Agda functions over a broad universe of datatypes, yet they can be specialized to native Agda datatypes with a simple one-liner. Furthermore, we provide building blocks so that library designers can too define their own datatype-generic constructions.

链接与引用

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

BibTeX
@article{paperbot1486,
  title = {Practical generic programming over a universe of native datatypes},
  author = {Lucas Escot and Jesper Cockx},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {6},
  number = {ICFP},
  year = {2022},
  doi = {10.1145/3547644}
}