Hazelnut: A Bidirectionally Typed Structure Editor Calculus
Not on the map. Why?
Abstract (arXiv)
Structure editors allow programmers to edit the tree structure of a program directly. This can have cognitive benefits, particularly for novice and end-user programmers. It also simplifies matters for tool designers, because they do not need to contend with malformed program text. This paper defines Hazelnut, a structure editor based on a small bidirectionally typed lambda calculus extended with holes and a cursor. Hazelnut goes one step beyond syntactic well-formedness: its edit actions operate over statically meaningful incomplete terms. Naively, this would force the programmer to construct terms in a rigid "outside-in" manner. To avoid this problem, the action semantics automatically places terms assigned a type that is inconsistent with the expected type inside a hole. This safely defers the type consistency check until the term inside the hole is finished. Hazelnut is a foundational type-theoretic account of typed structure editing, rather than an end-user tool itself. To that end, we describe how Hazelnut's rich metatheory, which we have mechanized in Agda, guides the definition of an extension to the calculus. We also discuss various plausible evaluation strategies for terms with holes, and in so doing reveal connections with gradual typing and contextual modal type theory, the Curry-Howard interpretation of contextual modal logic. Finally, we discuss how Hazelnut's semantics lends itself to implementation as a functional reactive program. Our reference implementation is written using js_of_ocaml.
Key facts. Cited by 8 papers in the map (data through 13 Oct 2026). First posted on arXiv 14 Jul 2016.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2021: 1; 2022: 0; 2023: 0; 2024: 1; 2025: 1; 2026: 5.
8 papers.
- 2024Statically Contextualizing Large Language Models with Typed Holescited by 9
- 2026LACUNA: Safe Agents as Recursive Program Holescited by 1
- 2021Report of the Workshop on Program Synthesis for Scientific Computingcited by 0
- 2025A generalised editor calculus (Short Paper)cited by 0
- 2026Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Codecited by 0
- 2026Volition Elicitation: Operational Semantics for People and Their Machinescited by 0
- 2026Decode-Time Grammars: Constrained LLM Generation over a Refinement Order of Grammar Fragmentscited by 0
- 2026Semantic Prefix Oracles for LLM Decoding: Contracts and Differential Validationcited by 0
- 2026Semantic Prefix Oracles for LLM Decoding: Contracts and Differential Validation28 Sep 2026
- 2026Decode-Time Grammars: Constrained LLM Generation over a Refinement Order of Grammar Fragments20 Jul 2026
- 2026Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Code15 Jul 2026
- 2026Volition Elicitation: Operational Semantics for People and Their Machines10 Jul 2026
- 2026LACUNA: Safe Agents as Recursive Program Holes27 May 2026
- 2025A generalised editor calculus (Short Paper)24 May 2025
- 2024Statically Contextualizing Large Language Models with Typed Holes2 Sep 2024
- 2021Report of the Workshop on Program Synthesis for Scientific Computing2 Feb 2021