Inside Cupid
A guided tour of the interpreter's source code.
A guided tour of the interpreter's source code, which follows a Haskell program through the stages that compile and run it. If you know Haskell and can read C, you have what it assumes.
Start with Reading Cupid in a day, which has the map of the source tree and a shorter route for a first day: five of these chapters, three of them in part. The list below is the order for the complete tour.
Getting your bearings
- Reading Cupid in a day — what a day's
reading gets you, the map of
src/, and a first-day route - The design of Cupid — the aim, and what is inherited from Gofer and Hugs
The path of a program
- How Cupid runs a program — one small program from the bytes in its file to its output
- Cells, text and tables — the one data type, the heap, the collector, and the checkpoints that reloading rests on
- How source is read — tokens, layout, trees, and finding the definitions behind names
- How types are inferred — learning types from uses, then storing them and inserting dictionary arguments
- How constraints are solved — where dictionaries come from, and how constraints inform types
- How code is compiled and run — pattern matching, lambda lifting, the abstract machine and its instructions
Around the pipeline
- The running interpreter — the modes, the subsystems, interrupts, signals and output
- Modules, files and the search path — how a module name becomes a file
- Foreign functions — stubs, and why callbacks into Haskell aren't available
- Character encoding — where bytes become characters
- Platforms and the build — why nothing is probed, and why there are so few options
- How the C is written — the conventions you'll see in every file
Why it is like this
- Why the language is what it is — how a feature gets in, and what stays out
- History — from Gofer to this tree