paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Compiling to categories

编译到范畴
ICFP 1(ICFP)2017匹配度 2/10 · 该论文属于函数式编译与范畴论语义方向,核心是将类型化程序编译到不同范畴,与用户关注的 LLM/Agentic 程序静态分析、AI 辅助形式化验证、浮点程序分析及贝叶斯程序分析均无直接关联;仅在自动微分、区间分析等具体解释上与浮点/数值分析有非常边缘的联系。引用 43 inbox
Conal Elliott
dblp: 2026-09-10crossref: 2026-09-10

AI 速览

一句话:将类型化函数式程序经保持语义的变换编译到不同范畴,以统一实现硬件电路、自动微分、增量计算等解释。

本文基于简单类型 lambda 演算可由任意笛卡尔闭范畴(CCC)建模这一事实,提出为类型化函数式程序赋予多种范畴解释。实现方式是在现有编译器(如 GHC)中加入一组保持语义的变换,将程序编译到目标范畴。每个解释只需在 Haskell 中(编译器之外)定义相应范畴,无需深层嵌入 DSL。作者展示了该方法在硬件电路、自动微分、增量计算和区间分析等场景的应用,并认为这种通用技术是深层嵌入领域特定语言的有力替代方案。

问题
如何为同一类型化函数式程序提供多种语义解释,并避免为每种应用重复构建深层嵌入 DSL?
方法
利用 CCC 与简单类型 lambda 演算的对应关系,在 GHC 等现有编译器中加入保持语义的变换,将程序编译到在 Haskell 中定义的各类范畴。
评估
通过实现原型并在硬件电路、自动微分、增量计算、区间分析等多种解释上演示其可用性。
原文摘要(Abstract)

It is well-known that the simply typed lambda-calculus is modeled by any cartesian closed category (CCC). This correspondence suggests giving typed functional programs a variety of interpretations, each corresponding to a different category. A convenient way to realize this idea is as a collection of meaning-preserving transformations added to an existing compiler, such as GHC for Haskell. This paper describes such an implementation and demonstrates its use for a variety of interpretations including hardware circuits, automatic differentiation, incremental computation, and interval analysis. Each such interpretation is a category easily defined in Haskell (outside of the compiler). The general technique appears to provide a compelling alternative to deeply embedded domain-specific languages.

链接与引用

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

BibTeX
@article{Elliott17a,
  title = {Compiling to categories},
  author = {Conal Elliott},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {1},
  number = {ICFP},
  year = {2017},
  doi = {10.1145/3110271}
}