Secrets of the GHC Typechecker in 100 Type Declarations
summary
Deep tour of GHC’s typechecker anchored in actual source: 50,000 lines of Haskell, modules like GHC.Tc.Gen (≈11k LOC), GHC.Tc.Solver (≈6k), GHC.Tc.Errors (≈9k), and concrete datatypes such as HsWrapper and HsExpansion. Shows the real pipeline: constraint generator → solver with zonking, meta-TcTyVars (IORef mutation), level numbers to prevent skolem escape, and how to trace with ddump-tc-trace/tc-trace. Works as presented — practical code pointers, debugging tips, and where to read and edit the Wiki. Watch if planning to modify or debug GHC’s typechecker.
AI-written summary · about
chapters (15)
- 0:00GHC typechecker intro
- 1:12Talk overview and compiler pipeline
- 2:37Trees That Grow design
- 8:48Extension fields and payload
- 13:59Source vs desugaring typecheck
- 18:20Desugaring in renamer and TC
- 21:13Type inference and constraints
- 30:09Constraint solving process
- 39:52Modular GHC typechecker
- 42:21Zonking and unification
- 57:06Checking vs inference
- 1:04:57Typechecker traces in action
- 1:12:20Implication constraints and dicts
- 1:23:12Level numbers and skolems
- 1:34:09Summary
related talks
49mMaking sense of the Haskell type system
01h 02mType Inference in GHC
01h 28mInto the Core Squeezing Haskell into nine Constructors
32mCode as Data: Extracting & Analyzing Info from Haskell Codebases
01h 04mHaskell - A Peek Inside the Ivory Tower
59mKeynote: Dependently-Typed Haskell
21mProduction Haskell Demystified
53mFalling Skies: Haskell Tooling and Ecosystem Growth
