Idea · Sep 2, 2026
Build Your Own Type Inferencer
Students implement a Hindley-Milner type inference engine for a small functional language, guided by a step-through visual debugger that animates constraint generation, unification, and the final type environment in real time.
What it would do
Type inference is one of the most elegant algorithms in programming languages, yet it is rarely taught hands-on because the implementation is intricate. This multi-week project gives students a scaffolded starter language (a subset of ML with let, lambda, and if/then/else), a specification of the HM constraint-generation rules, and a React-based visual debugger that animates each step: which constraints were generated for each AST node, which pairs the unifier is resolving, and what the substitution set looks like after each step. Students fill in the key functions (generate_constraints, unify, apply_substitution) in Python or JavaScript, run their implementation against a test suite of 30+ typed and ill-typed programs, and compare their output against a reference implementation. A stretch goal adds let-polymorphism. Appropriate for upper-division PL courses or graduate PL seminars.
Key features
- Scaffolded mini-ML starter language with AST defined and parser provided
- Step-through visual debugger for constraint generation and unification steps
- Test suite of 30+ typed and ill-typed programs with expected types or type errors
- Reference implementation for self-checking and debugging
- Stretch goals: let-polymorphism (generalization and instantiation) and algebraic data types