paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Live functional programming with typed holes

带类型洞的实时函数式编程
POPL 3(POPL)2019匹配度 2/10 · 论文属于纯PL/类型论与活编程环境,研究带类型洞的不完整程序动态语义,虽有形式化与工程实现,但未涉及LLM/Agent、静态分析、浮点程序分析或贝叶斯程序分析等用户核心方向。引用 66 inbox
Cyrus Omar, Ian Voysey, Ravi Chugh, Matthew A. Hammer
crossref: 2026-09-10

AI 速览

一句话:提出带类型洞的不完整函数式程序动态语义,求值可绕过洞并支持填洞后恢复,已在Agda机器化并实现于Hazel。

实时编程环境希望随编辑持续反馈动态行为,但传统语言只对完整且类型正确的程序赋予动态意义,造成反馈缺口。本文从类型论第一原理出发,为不完整函数式程序建立动态语义:程序是带洞表达式,空穴表示缺失表达式或类型,非空穴作为类型不一致的膜;求值绕过洞并跟踪洞实例的闭包。洞闭包支持编辑器服务理解程序,并支持填洞后恢复求值。语义结合渐进类型论与上下文模态类型论,保持类型安全。作者在Agda中机器化Hazelnut Live,并在Hazel中实现,保证每个可达编辑状态都有(可能不完整的)类型,实现无缺口反馈。

问题
实时编程环境希望持续反馈程序动态行为,但传统语言只为完整且类型正确的程序赋予动态意义,导致反馈存在时间或感知缺口。
方法
本文从类型论第一原理出发,为带洞的不完整函数式程序定义动态语义,结合渐进类型论与上下文模态类型论,引入洞闭包使求值绕过洞并支持填洞后恢复。
评估
作者在Agda中机器化核心演算Hazelnut Live并证明类型安全,并在Hazel环境中实现,保证每个可达编辑状态都有(可能不完整的)类型,从而验证无缺口动态反馈的可行性。
原文摘要(Abstract)

Live programming environments aim to provide programmers (and sometimes audiences) with continuous feedback about a program's dynamic behavior as it is being edited. The problem is that programming languages typically assign dynamic meaning only to programs that are complete, i.e. syntactically well-formed and free of type errors. Consequently, live feedback presented to the programmer exhibits temporal or perceptive gaps. This paper confronts this "gap problem" from type-theoretic first principles by developing a dynamic semantics for incomplete functional programs, starting from the static semantics for incomplete functional programs developed in recent work on Hazelnut. We model incomplete functional programs as expressions with holes, with empty holes standing for missing expressions or types, and non-empty holes operating as membranes around static and dynamic type inconsistencies. Rather than aborting when evaluation encounters any of these holes as in some existing systems, evaluation proceeds around holes, tracking the closure around each hole instance as it flows through the remainder of the program. Editor services can use the information in these hole closures to help the programmer develop and confirm their mental model of the behavior of the complete portions of the program as they decide how to fill the remaining holes. Hole closures also enable a fill-and-resume operation that avoids the need to restart evaluation after edits that amount to hole filling. Formally, the semantics borrows machinery from both gradual type theory (which supplies the basis for handling unfilled type holes) and contextual modal type theory (which supplies a logical basis for hole closures), combining these and developing additional machinery necessary to continue evaluation past holes while maintaining type safety. We have mechanized the metatheory of the core calculus, called Hazelnut Live, using the Agda proof assistant. We have also implemented these ideas into the Hazel programming environment. The implementation inserts holes automatically, following the Hazelnut edit action calculus, to guarantee that every editor state has some (possibly incomplete) type. Taken together with this paper's type safety property, the result is a proof-of-concept live programming environment where rich dynamic feedback is truly available without gaps, i.e. for every reachable editor state.

链接与引用

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

BibTeX
@article{paperbot641,
  title = {Live functional programming with typed holes},
  author = {Cyrus Omar and Ian Voysey and Ravi Chugh and Matthew A. Hammer},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {3},
  number = {POPL},
  year = {2019},
  doi = {10.1145/3290327}
}