一句话:从类型论角度研究带类型洞的模式匹配,并将其实现为 Hazel 的完全实时编程环境。
现有支持类型洞的编程系统仅考虑表达式和类型中的洞。本文研究模式洞:当模式未完全确定时,如何静态判断匹配的穷尽性与冗余性,以及如何对同时含模式洞和表达式洞的程序进行实时求值。作者提出带类型 λ 演算 Peanut,将穷尽性与冗余性归约为一阶蕴含判定,并给出类似 Hazelnut Live 的操作语义以在洞周围求值;在 Agda 中机器化元理论并形式化蕴含判定过程。最后在 Elm 方言环境 Hazel 中实现,使其在任意编辑状态下自动插入洞并提供静态与动态反馈,成为首个面向通用函数式语言的完全实时环境。
Several modern programming systems, including GHC Haskell, Agda, Idris, and Hazel, support typed holes . Assigning static and, to varying degree, dynamic meaning to programs with holes allows program editors and other tools to offer meaningful feedback and assistance throughout editing, i.e. in a live manner. Prior work, however, has considered only holes appearing in expressions and types. This paper considers, from type theoretic and logical first principles, the problem of typed pattern holes. We confront two main difficulties, (1) statically reasoning about exhaustiveness and irredundancy when patterns are not fully known, and (2) live evaluation of expressions containing both pattern and expression holes. In both cases, this requires reasoning conservatively about all possible hole fillings. We develop a typed lambda calculus, Peanut, where reasoning about exhaustiveness and redundancy is mapped to the problem of deriving first order entailments. We equip Peanut with an operational semantics in the style of Hazelnut Live that allows us to evaluate around holes in both expressions and patterns. We mechanize the metatheory of Peanut in Agda and formalize a procedure capable of deciding the necessary entailments. Finally, we scale up and implement these mechanisms within Hazel, a programming environment for a dialect of Elm that automatically inserts holes during editing to provide static and dynamic feedback to the programmer in a maximally live manner, i.e. for every possible editor state. Hazel is the first maximally live environment for a general-purpose functional language.
@article{paperbot2033,
title = {Live Pattern Matching with Typed Holes},
author = {Yongwei Yuan and Scott Guest and Eric Griffis and Hannah Potter and David Moon and Cyrus Omar},
journal = {Proceedings of the ACM on Programming Languages},
volume = {7},
number = {OOPSLA1},
year = {2023},
doi = {10.1145/3586048}
}