Live Functional Programming with Typed Holes

被引:29
|
作者
Omar, Cyrus [1 ]
Voysey, Ian [2 ]
Chugh, Ravi [1 ]
Hammer, Matthew A. [3 ]
机构
[1] Univ Chicago, Chicago, IL 60637 USA
[2] Carnegie Mellon Univ, Pittsburgh, PA 15213 USA
[3] Univ Colorado, Boulder, CO 80309 USA
基金
美国国家科学基金会;
关键词
live programming; gradual typing; contextual modal type theory; typed holes; structured editing;
D O I
10.1145/3290327
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
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 1111 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.
引用
收藏
页数:32
相关论文
共 50 条
  • [1] Filling Typed Holes with Live GUIs
    Omar, Cyrus
    Moon, David
    Blinn, Andrew
    Voysey, Ian
    Collins, Nick
    Chugh, Ravi
    [J]. PROCEEDINGS OF THE 42ND ACM SIGPLAN INTERNATIONAL CONFERENCE ON PROGRAMMING LANGUAGE DESIGN AND IMPLEMENTATION (PLDI '21), 2021, : 511 - 525
  • [2] TYPED FUNCTIONAL PROGRAMMING
    HUANG, WT
    YOU, DC
    [J]. SIGPLAN NOTICES, 1986, 21 (02): : 22 - 26
  • [3] Live Pa∼ern Matching with Typed Holes
    Yuan, Yongwei
    Guest, Scott
    Griffis, Eric
    Potter, Hannah
    Moon, David
    Omar, Cyrus
    [J]. PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL, 2023, 7 (OOPSLA):
  • [4] Typed contracts for functional programming
    Hinze, Ralf
    Jeuring, Johan
    Loh, Andres
    [J]. FUNCTIONAL AND LOGIC PROGRAMMING, PROCEEDINGS, 2006, 3945 : 208 - 225
  • [5] A TYPED FUNCTIONAL EXTENSION OF LOGIC PROGRAMMING
    SHIN, DW
    NANG, JH
    MAENG, SR
    CHO, JW
    [J]. NEW GENERATION COMPUTING, 1992, 10 (02) : 197 - 221
  • [6] Automation for Dependently Typed Functional Programming
    Wilson, Sean
    Fleuriot, Jacques
    Smaill, Alan
    [J]. FUNDAMENTA INFORMATICAE, 2010, 102 (02) : 209 - 228
  • [7] Function Passing: A Model for Typed, Distributed Functional Programming
    Miller, Heather
    Haller, Philipp
    Mueller, Normen
    Boullier, Jocelyn
    [J]. ONWARD!'16: PROCEEDINGS OF THE 2016 ACM INTERNATIONAL SYMPOSIUM ON NEW IDEAS, NEW PARADIGMS, AND REFLECTIONS ON PROGRAMMING AND SOFTWARE, 2016, : 82 - 97
  • [8] High-Level Modelling for Typed Functional Programming
    Motara, Yusuf Moosa
    [J]. TRENDS IN FUNCTIONAL PROGRAMMING (TFP 2021), 2021, 12834 : 69 - 94
  • [9] Security-Typed Programming within Dependently Typed Programming
    Morgenstern, Jamie
    Licata, Daniel R.
    [J]. ICFP 2010: PROCEEDINGS OF THE 2010 ACM SIGPLAN INTERNATIONAL CONFERENCE ON FUNCTIONAL PROGRAMMING, 2010, : 169 - 180
  • [10] Security-Typed Programming within Dependently Typed Programming
    Morgenstern, Jamie
    Licata, Daniel R.
    [J]. ACM SIGPLAN NOTICES, 2010, 45 (09) : 169 - 180