Live Functional Programming with Typed Holes

by   Cyrus Omar, et al.

This paper develops a dynamic semantics for incomplete functional programs, based in part on the static semantics for incomplete functional programs developed in our recent work. 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 with an exception when evaluation encounters any of these holes (as in several existing systems), evaluation proceeds "around" the holes, performing as much of the remaining computation as is possible and tracking the closure around each hole instance as it flows through the program. Various editor services can report information from these hole closures to help the programmer decide how to fill a hole. They also enable a "fill-and-resume" feature that avoids the need to restart evaluation after edits that amount to hole filling. Formally, the semantics draws from both gradual type theory (to handle type holes) and contextual modal type theory (which provides a logical foundation for hole closures), and develops additional technical machinery necessary to continue evaluation past the various hole forms and to prove important metatheoretic properties. We have mechanized the core formal development using the Agda proof assistant. We also describe a simple implementation, called HazelnutLive, that inserts holes as necessary during the editing process to guarantee that every edit state has some (possibly incomplete) type, based in part on the Hazelnut edit action calculus in our recent work. Taken together with the type safety property that this paper establishes, the result is a proof-of-concept live typed functional programming environment where dynamic feedback is truly continuous, i.e. it is available for every possible edit state.


page 4

page 39


Maniposynth: Bimodal Tangible Functional Programming

Traditionally, writing code is a non-graphical, abstract, and linear pro...

Formalising Type-Logical Grammars in Agda

In recent years, the interest in using proof assistants to formalise and...

Live, Rich, and Composable: Qualities for Programming Beyond Static Text

Efforts to push programming beyond static textual code have sought to im...

Imperative Functional Programs that Explain their Work

Program slicing provides explanations that illustrate how program output...

The Semantics of Rank Polymorphism

Iverson's APL and its descendants (such as J, K and FISh) are examples o...

Reasoning about the garden of forking paths

Lazy evaluation is a powerful tool for functional programmers. It enable...

Distribution Theoretic Semantics for Non-Smooth Differentiable Programming

With the wide spread of deep learning and gradient descent inspired opti...

Please sign up or login with your details

Forgot password? Click here to reset