How GHC compiles Haskell

A guided tour of the Glasgow Haskell Compiler, assembled from its own source: the 3,270 Note […] comments in which its authors recorded why it is built the way it is. Pinned to ghc-9.14.1-release.

Follow one module through GHC Start with the parser Browse the Notes →

The pipeline

Each phase is sized by how much design reasoning it carries. Phases with a chapter are live; the rest are mapped but not yet written up.

The runtime

Compiled code does not run alone. The RTS provides the storage manager, the scheduler, and the machinery that makes laziness and concurrency work.

  1. Runtime system C, Cmm, and assembly Garbage collection, the lightweight thread scheduler, STM, and the evaluation machinery itself. 184 notes Read →