Explaining type inference

Dominic Duggan, Frederick Bent

Research output: Contribution to journalArticlepeer-review

58 Scopus citations

Abstract

Type inference is the compile-time process of reconstructing missing type information in a program based on the usage of its variables. ML and Haskell are two languages where this aspect of compilation has enjoyed some popularity, allowing type information to be omitted while static type checking is still performed. Type inference may be expected to have some application in the prototyping and scripting languages which are becoming increasingly popular. A difficulty with type inference is the confusing and sometimes counter-intuitive diagnostics produced by the type checker as a result of type errors. A modification of the unification algorithm used in Hindley-Milner type inference is presented, which allows the specific reasoning which led to a program variable having a particular type to be recorded for type explanation. This approach is close to the intuitive process used in practice for debugging type errors. The algorithm is practical, and has been implemented in the Standard ML of New Jersey compiler. The modified unification algorithm also appears useful in other domains, including logic program debuggers and semantics-based programming environments.

Original languageEnglish
Pages (from-to)37-83
Number of pages47
JournalScience of Computer Programming
Volume27
Issue number1
DOIs
StatePublished - Jul 1996

Fingerprint

Dive into the research topics of 'Explaining type inference'. Together they form a unique fingerprint.

Cite this