Typical: Taking the Tedium Out of Typing

Robert Grimm, Laune Harris, Anh Le. Typical: Taking the Tedium Out of Typing. NYU CS Technical Report TR2007-904, New York University, New York, November 2007.

Abstract

The implementation of real-world type checkers requires a nontrivial engineering effort. The resulting code easily comprises thousands of lines, which increases the probability of software defects in a component critical to compiler correctness. To make type checkers easier to implement and extend, this paper presents Typi- cal, a domain-speciļ¬c language and compiler that directly and concisely captures the structure of type systems. Our language builds on the functional core for ML to represent syntax trees and types as variants and to traverse them with pattern matches. It then adds declarative constructs for common type checker concerns, such as scoping rules, namespaces, and constraints on types. It also integrates error checking and reporting with other constructs to promote comprehensive error management. We have validated our system with two real-world type checkers written in Typical, one for Typical itself and the other for C.