With this project, I aim to collect reference implementations of type inference algorithms, with particular emphasis on those features which are necessary for practical implementations, such as error reporting and incrementality.
- The original code is based off of Stephen Diehl's "Write You a Haskell" series (and corrections), but the implementation has diverged substantially.
- The name (and project) is inspired by Andrej Bauer and Matija Pretnar's "Programming Language Zoo" and Andras Kovacs' "Elaboration Zoo". I briefly considered Type Petting Zoo for the name, but thought it might be a bit too silly :)
- Stephen Dolan's "Counterexamples in Type Systems"
- implement a wide range of type inference algorithms in a consistent style to facilitate comparison
- maintain a clear correspondence between typing judgements on paper and Haskell code
- develop a generic web interface (not necessarily a language server, but something similar) for debugging and for comparing the behavior of different type systems.
- should show detailed typing information about the typing context at each source position
- if possible, allow the user to interactively step through the inference procedure
Hindley-Milner & Extensions
- Algorithm W
- Algorithm M
- Constraint Generation & First-Order Unification
- Type Annotations
- Typed Holes
- Recursive Definitions
- Mutual Recursion
- Pattern Matching
- Local vs. Top-Level
- Higher Rank Polymorphism
- Row Polymorphism
- Units of Measure, Commutative Group Unification a la Gundry 2013
Normalization by Evaluation
Type Inference for Dependent Types
- Calculus of Constructions
- Calculus of Inductive Constructions
- Bidirectional Type Inference
- Higher-Order Unification, Pattern Unification
Here are some topics I hope to cover, but I'm not quite sure how/where they fit in:
- interacttions between Hindley-Milner and subtyping
- subsumption, and Haskell's "simplified subsumption"
- Stephen Dolan's Algebraic Subtyping
- ML's value restriction, and OCaml's relaxation of the value restriction
Hindley-Milner
- Ben Lynn, "Hindley-Milner Type Inference (Outcoding Unix Geniuses)"
- Okmij, "How OCaml Type Checker Works -- or What Polymorphism and Garbage Collection Have in Common"
- explains Rémy's "efficient level-based generalization" Rémy 1992, "Extension of ML Type System with a Sorted Equational Theory on Types"
- StackOverflow, "What part of Hindley-Milner do you not understand?"
- Jones 2000, "Typing Haskell in Haskell"
- Brian McKenna 2013, "Bottom-Up Type Annotation with the Cofree Comonad"
- a partial implementation (missing let-generalization) of Heeren2002's constraint-based Hindley-Milner using
Cofree
to represent annotated AST
- a partial implementation (missing let-generalization) of Heeren2002's constraint-based Hindley-Milner using
- Kaminski 2010, "Who ordered skolem constants?" (and discussion)
- Vytiniotis 2010, "Let should not be Generalized"
System F
- Ben Lynn, "System F"
Bidirectional Type Inference
- Pfenning 2004, "Lecture Notes on Bidirectional Type-Checking"
- Pierce & turner 2000, "Local Type Inference"
- Type inference algorithms have not caught up with the development of type systems, because it is hard to guarantee completeness. Instead, this paper presents a bidirectional local type inference algorithm for partial type inference.
- Dunfield & Krishnaswami 2013, "Complete and Easy Bidirectional Typechecking for Higher-Rank Polymorphism"
Optimizations
- Gamari 2019, "Writing Efficient Free Variable Traversals"
Miscellaneous
- Scott 2019, "The Surprising Rigidness of Higher-Rank Kinds"