Reference. Contextualized Programming Language Documentation
Cite
Cited by (2)
Hazel Deriver: A Live Editor for Constructing Rule-Based Derivations zhong-2025-hazel
Total Type Error Localization and Recovery with Holes zhao-2024-total
Type systems typically only define the conditions under which an expression is well-typed, leaving ill-typed expressions formally meaningless. This approach is insufficient as the basis for language servers driving modern programming environments, which are expected to recover from simultaneously localized errors and continue to provide a variety of downstream semantic services. This paper addresses this problem, contributing the first comprehensive formal account of total type error localization and recovery: the marked lambda calculus. In particular, we define a gradual type system for expressions with marked errors, which operate as non-empty holes, together with a total procedure for marking arbitrary unmarked expressions. We mechanize the metatheory of the marked lambda calculus in Agda and implement it, scaled up, as the new basis for Hazel, a full-scale live functional programming environment with, uniquely, no meaningless editor states. The marked lambda calculus is bidirectionally typed, so localization decisions are systematically predictable based on a local flow of typing information. Constraint-based type inference can bring more distant information to bear in discovering inconsistencies but this notoriously complicates error localization. We approach this problem by deploying constraint solving as a type-hole-filling layer atop this gradual bidirectionally typed core. Errors arising from inconsistent unification constraints are localized exclusively to type and expression holes, i.e., the system identifies unfillable holes using a system of traced provenances, rather than localized in an ad hoc manner to particular expressions. The user can then interactively shift these errors to particular downstream expressions by selecting from suggested partially consistent type hole fillings, which returns control back to the bidirectional system. We implement this type hole inference system in Hazel.
Cites 29 works (3 here)
With notes (3)
Live functional programming with typed holes omar-2019-live
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.
Reasonably programmable literal notation omar-2018-reasonably
General-purpose programming languages typically define literal notation for only a small number of common data structures, like lists. This is unsatisfying because there are many other data structures for which literal notation might be useful, e.g. finite maps, regular expressions, HTML elements, SQL queries, syntax trees for various languages and chemical structures. There may also be different implementations of each of these data structures behind a common interface that could all benefit from common literal notation. This paper introduces typed literal macros (TLMs) , which allow library providers to define new literal notation of nearly arbitrary design at any specified type or parameterized family of types. Compared to existing approaches, TLMs are uniquely reasonable . TLM clients can reason abstractly, i.e. without examining grammars or generated expansions, about types and binding. The system only needs to convey to clients, via secondary notation, the inferred segmentation of each literal body, which gives the locations and types of spliced subterms. TLM providers can reason modularly about syntactic ambiguity and expansion correctness according to clear criteria. This paper incorporates TLMs into Reason, an emerging alternative front-end for OCaml, and demonstrates, through several non-trivial case studies, how TLMs integrate with the advanced features of OCaml, including pattern matching and the module system. We also discuss optional integration with MetaOCaml, which allows TLM providers to be more confident about type correctness. Finally, we establish these abstract reasoning principles formally with a detailed type-theoretic account of expression and pattern TLMs for “core ML”.
Hazelnut: a bidirectionally typed structure editor calculus omar-2017-hazelnut
External (26)
- Here we go again: why is it difficult for developers to learn another programming language? (2022)
- Augmenting Scientific Papers with Just-in-Time, Position-Sensitive Definitions of Terms and Symbols (2021)
- The vote Package: Single Transferable Vote and Other Electoral Systems in R (2021)
- A New Medium for Communicating Research on Programming Languages (2021)
- Hazel (live functional programming environment) (2021)
- Engage Against the Machine: Rise of the Notional Machines as Effective Pedagogical Devices (2020)
- The Design Space of Computational Notebooks: An Analysis of 60 Systems in Academia and Industry (2020)
- Hazel Tutor: Guiding Novices Through Type-Driven Development Strategies (2020)
- A Human Study of Comprehension and Code Summarization (2020)
- Notional Machines and Programming Language Semantics in Education (Dagstuhl Seminar 19281) (2019)
- A Neural Model for Generating Natural Language Summaries of Program Subroutines (2019)
- The Effect of Reading Code Aloud on Comprehension: An Empirical Study with School Students (2019)
- Introductory programming: a systematic literature review (2018)
- Coqatoo: Generating Natural Language Versions of Coq Proofs (2017)
- Dual Modality Code Explanations for Novices (2017)
- Toward Semantic Foundations for Program Editors (2017)
- Students’ Misconceptions and Other Difficulties in Introductory Programming (2017)
- SimpleScience: Lexical Simplification of Scientific Terminology (2016)
- CodeMend: Assisting Interactive Programming with Bimodal Embedding (2016)
- Tutorons: Generating context-relevant, on-demand explanations and demonstrations of online code (2015)
- Understanding understanding source code with functional magnetic resonance imaging (2014)
- Online python tutor: embeddable web-based program visualization for cs education (2013)
- Learnable Programming: Designing a programming system for understanding programs (2012)
- An empirical comparison of the accuracy rates of novices using the quorum, perl, and randomo programming languages (2011)
- Should we leverage natural-language knowledge? An analysis of user errors in a natural-language-style programming language (1999)
- Verbalization of High-Level Formal Proofs (1999)