arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1909.04160cs.PL
收藏

Haskell中的结构和语义模式匹配分析

Structural and semantic pattern matching analysis in Haskell

Pavel Kalvoda, Tom Sydney Kerckhove

摘要:

Haskell函数被定义为一系列由模式组成的子句,这些模式按照定义的顺序与参数相匹配。如果输入与任何子句都不匹配,则会发生错误。因此,需要静态地证明函数是为所有类型良好的输入定义的。相反,一个永远无法匹配的子句也表明可能存在缺陷。由于存在GADT和守卫以及Haskell的惰性计算,分析这些属性是具有挑战性的。我们实现了一个最近提出的算法,统一和扩展的格拉斯哥Haskell算法的第7版中实现的相关分析。通过使用SMT求解器来处理模式守卫所产生的语义约束,我们实现了对现有GHC 8.0.1实现的精度的进一步提高。我们提出了一个工具,使用的分析,给声音,更精确,和可操作的警告程序缺陷。

英文摘要:

Haskell functions are defined as a series of clauses consisting of patterns that are matched against the arguments in the order of definition. In case an input is not matched by any of the clauses, an error occurs. Therefore it is desirable to statically prove that the function is defined for all well-typed inputs. Conversely, a clause that can never be matched also indicates a likely defect. Analyzing these properties is challenging due to presence of GADT and guards as well as due to Haskell's lazy evaluation. We implement a recently proposed algorithm that unifies and extends the related analyses implemented in version 7 of the Glasgow Haskell Compiler. By using an SMT solver to handle the semantic constraints arising from pattern guards, we achieve a further improvement in precision over the existing GHC 8.0.1 implementation. We present a tool that uses the analysis to give sound, more precise, and actionable warnings about program defects.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑