Technical reports
Type error debugging in Hazel
Max Carroll
July 2026, 83 pages
This technical report is based on a dissertation submitted May 2025 by the author for the degree of Bachelor of Arts (Computer Science Tripos) to the University of Cambridge, Sidney Sussex College.
Some figures in this document are best viewed in colour. If you received a black-and-white copy, please consult the online version if necessary.
| DOI | https://doi.org/10.48456/tr-1006 |
Abstract
This report seeks to improve the debugging of type errors in Hazel, a gradually typed functional language supporting incomplete programs, by explaining static type errors more completely and by combining the benefits of static and dynamic type errors. Three methods are developed. Type slicing highlights the code that determines an expression’s synthesised or analysed type, explaining not just where a static error occurred but why; it generalises beyond errors, applying to all expressions. Cast slicing propagates type slices through evaluation, attaching to each runtime cast a slice of the source code that gave rise to it, recovering the source context of dynamic type errors. A type error witness search procedure, built on indeterminate evaluation, automatically finds inputs witnessing a dynamic counterpart to a static error, linking the two classes of errors. All three methods are given mathematical foundations over a core bidirectionally and gradually typed calculus of functions, holes, and casts; the implementation in the Hazel programming environment extends considerably beyond this formalised fragment, covering nearly the full language. The methods are evaluated on a corpus of ill-typed Hazel programs, with the best search strategy failing to find existing dynamic witnesses for only 2% of the corpus.
Full text
PDF (2.8 MB)
BibTeX record
@TechReport{UCAM-CL-TR-1006,
author = {Carroll, Max},
title = {{Type error debugging in Hazel}},
year = 2026,
month = jul,
url = {https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-1006.pdf},
institution = {University of Cambridge, Computer Laboratory},
doi = {10.48456/tr-1006},
number = {UCAM-CL-TR-1006}
}