paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Lower your guards: a compositional pattern-match coverage checker

Lower your guards:一个组合式的模式匹配覆盖检查器
ICFP 4(ICFP)2020匹配度 3/10 · 该论文属于程序语言与编译器静态分析方向,提出了模式匹配覆盖检查算法并在 GHC 中落地,具备理论形式化与工程实现,和用户对静态分析的一般兴趣有弱交集;但完全不涉及 LLM/Agentic 程序、浮点程序分析或贝叶斯程序分析,因此不匹配当前研究核心。引用 10 inbox
Sebastian Graf, Simon Peyton Jones, Ryan G. Scott
dblp: 2026-09-10crossref: 2026-09-10

AI 速览

一句话:提出 Lower Your Guards 算法,将模式匹配归约为守卫树,简化覆盖检查,并在 GHC 中实现,提升准确性和性能。

编译器应警告模式匹配未覆盖输入(缺失或冗余模式),但现代语言特性繁多,准确生成警告困难,尤其在 Haskell 中,GHC 扩展使模式语言极其复杂,现有覆盖检查器仍会报告不准确警告。本文提出 Lower Your Guards 算法,将模式匹配的复杂性归结为守卫树(guard trees),守卫树只有三种构造,极大简化了覆盖检查过程。该算法模块化,易于扩展支持新源语言模式。作者在 GHC 中实现了该算法,并展示其在准确性和性能上均优于 GHC 当前的覆盖检查器。

问题
编译器需要准确警告模式匹配中的缺失或冗余模式,但 Haskell 及其 GHC 扩展使模式语言复杂,现有覆盖检查器常产生不准确警告。
方法
提出 Lower Your Guards 算法,将源语言模式匹配归结为只有三种构造的守卫树,从而简化覆盖检查,且算法模块化,便于扩展。
评估
在 GHC 中实现该算法,并与现有覆盖检查器对比,展示了在准确性和性能上的改进。
原文摘要(Abstract)

A compiler should warn if a function defined by pattern matching does not cover its inputs—that is, if there are missing or redundant patterns. Generating such warnings accurately is difficult for modern languages due to the myriad of language features that interact with pattern matching. This is especially true in Haskell, a language with a complicated pattern language that is made even more complex by extensions offered by the Glasgow Haskell Compiler (GHC). Although GHC has spent a significant amount of effort towards improving its pattern-match coverage warnings, there are still several cases where it reports inaccurate warnings. We introduce a coverage checking algorithm called Lower Your Guards, which boils down the complexities of pattern matching into guard trees . While the source language may have many exotic forms of patterns, guard trees only have three different constructs, which vastly simplifies the coverage checking process. Our algorithm is modular, allowing for new forms of source-language patterns to be handled with little changes to the overall structure of the algorithm. We have implemented the algorithm in GHC and demonstrate places where it performs better than GHC’s current coverage checker, both in accuracy and performance.

链接与引用

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

BibTeX
@article{GrafJS20,
  title = {Lower your guards: a compositional pattern-match coverage checker},
  author = {Sebastian Graf and Simon Peyton Jones and Ryan G. Scott},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {4},
  number = {ICFP},
  year = {2020},
  doi = {10.1145/3408989}
}