Making a Language

This is a series that teaches you how to make a programming language. Our language's implementation can be divided up into passes: Typechecking, Lowering, etc. Each pass has a section below that is subdivided into features for the language. We can see "Types" (our first pass about type inference) is subdivided into three features: Base, Rows, Items.

Each feature layers new capabilities atop the previous feature. Base is the initial feature, and Rows layers support for row types on top of the Base language (and Item layers on Rows etc). Pass/feature combos connect together. Lowering/Base depends on Types/Base, and at the end we can combine all our passes' Base features to create a compiler for our Base language.

You can read each feature set for a pass, or you can read each pass for a feature. Implementation code is available in the accompanying repo

Types

Types introduces the Abstract Syntax Tree (AST) for our language and starts us off by inferring types for our AST.

Base

Typechecking a Language without a Parser
June 17, 2023 Designing a language, types first
Bidirectional Constraint Generation
June 24, 2023 Generate Type Constraints with a Bidirectional Type System
Tying up Type Inference
July 1, 2023 Solve Type Constraints via Unification

Rows

Rowing Afloat Datatype Boats
October 21, 2023 Row, row, row your types

Items

TypeChecking Top Level Functions
July 5, 2024 Adding support for annotated top level items to our type checker

Lowering

Lowering turns our typed AST into our Intermediate Representation (IR). This shifts us from the frontend of the compiler to the middle/backend of the compiler.

Base

Lowering Our AST to Escape the Typechecker
January 28, 2025 Lowering our typed base AST into a System-F based IR
Escaping the Typechecker, an Implementation
February 4, 2025 Implementation of our lowering function

Rows

Lowering Row Types, Evidently
February 11, 2025 Explaining how we'll lower row types into our IR
The Types of Lowered Rows
February 18, 2025 Lowering row evidence from our type scheme
The Heart of Lowered Rows
February 26, 2025 Lowering row asts by generating evidence terms

Items

Lowering Top Level Items
March 4, 2025 Lowering top level items into our IR. A more elaborate affair than anticipated.