paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Datatype-generic programming meets elaborator reflection

数据类型泛型编程遇上 elaborator 反射
ICFP 6(ICFP)2022匹配度 1/10 · 论文属于依赖类型语言中的泛型编程与元编程(elaborator reflection),与用户关注的AI与PL交叉(静态分析、LLM辅助形式化验证、浮点/贝叶斯程序分析)无直接关联,且不涉及LLM或Agent。引用 2 inbox
Hsiang-Shang Ko, Liang-Ting Chen, Tzu-Chi Lin
crossref: 2026-09-10

AI 速览

一句话:提出基于 elaborator 反射的 Agda 框架,使数据类型泛型程序可直接实例化到原生数据类型与函数。

在 Agda 等依赖类型语言中,数据类型泛型编程自然且有用,但现有泛型库通常只作用于由库自身数据类型描述解码出的类型,导致不同泛型库难以互操作,也无法直接用于程序员更偏好的原生数据类型。本文基于 elaborator reflection 提出一个 Agda 框架,提供一组通用元程序,可将 datatype-generic 程序实例化为面向原生数据类型和函数(包括宇宙多态类型)的形式,且实例化方式对程序员友好、可定制。该工作预期能让基于此框架构建的泛型库对实践中的 Agda 程序员更具吸引力;随着 elaborator reflection 特性普及,该设计也可移植到其他语言。

问题
Agda 中数据类型泛型库通常只针对自身描述解码的数据类型,无法复用于原生数据类型,也无法与其他泛型库组合。
方法
利用 elaborator reflection 编写通用元程序,把 datatype-generic 程序实例化为原生数据类型与函数(含 universe-polymorphic 类型),并提供可定制、程序员友好的实例化形式。
评估
在 Agda 中实现该框架,并展示其能覆盖一系列有用的原生数据类型与函数;同时论证设计可随 elaborator reflection 的普及移植到其他语言。
原文摘要(Abstract)

Datatype-generic programming is natural and useful in dependently typed languages such as Agda. However, datatype-generic libraries in Agda are not reused as much as they should be, because traditionally they work only on datatypes decoded from a library’s own version of datatype descriptions; this means that different generic libraries cannot be used together, and they do not work on native datatypes, which are preferred by the practical Agda programmer for better language support and access to other libraries. Based on elaborator reflection, we present a framework in Agda featuring a set of general metaprograms for instantiating datatype-generic programs as, and for, a useful range of native datatypes and functions —including universe-polymorphic ones— in programmer-friendly and customisable forms. We expect that datatype-generic libraries built with our framework will be more attractive to the practical Agda programmer. As the elaborator reflection features used by our framework become more widespread, our design can be ported to other languages too.

链接与引用

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

BibTeX
@article{paperbot1496,
  title = {Datatype-generic programming meets elaborator reflection},
  author = {Hsiang-Shang Ko and Liang-Ting Chen and Tzu-Chi Lin},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {6},
  number = {ICFP},
  year = {2022},
  doi = {10.1145/3547629}
}