(WIP) Python implementations of various type checkers and interpreters as described in Types and Programming Languages by Benjamin Pierce.
Each subdirectory is a self-contained program, with run.py
being the main entrypoint.
arith
: A simple interpreter with basic numeric expressions to start things off.untyped
: Implementation of the untyped lambda calculus, as covered in chapters 5-7.simplebool
: Simply-typed calculus supportingBool
andArrow
(function) types andif-then-else
statements, from chapters 9-10.rcdsub
: Calculus involvingRecord
types and sub-typing relation between types. Supports bothTop
andBot
types. Covers chapters 15-17.recon
: Implementation of Hindley-Milner type inference algorithm on the simply-typed calculus by equality constraint generation, as described in chapter 22.system_f
: Includes the typechecker for lambda calculus with parametric polymorphism (SystemF). Supports both universal, and existential types.- ... TODO :)
- Mostly stays close to the original implementation in OCaml
- Makes heavy use of Python 3.10's new
match
statements for pattern matching - Parsing is done using
Lark
. Not focusing on efficiency of the parser