Cupid

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

  1. Reading Cupid in a day — what a day's reading gets you, the map of src/, and a first-day route
  2. The design of Cupid — the aim, and what is inherited from Gofer and Hugs

The path of a program

  1. How Cupid runs a program — one small program from the bytes in its file to its output
  2. Cells, text and tables — the one data type, the heap, the collector, and the checkpoints that reloading rests on
  3. How source is read — tokens, layout, trees, and finding the definitions behind names
  4. How types are inferred — learning types from uses, then storing them and inserting dictionary arguments
  5. How constraints are solved — where dictionaries come from, and how constraints inform types
  6. How code is compiled and run — pattern matching, lambda lifting, the abstract machine and its instructions

Around the pipeline

  1. The running interpreter — the modes, the subsystems, interrupts, signals and output
  2. Modules, files and the search path — how a module name becomes a file
  3. Foreign functions — stubs, and why callbacks into Haskell aren't available
  4. Character encoding — where bytes become characters
  5. Platforms and the build — why nothing is probed, and why there are so few options
  6. How the C is written — the conventions you'll see in every file

Why it is like this

  1. Why the language is what it is — how a feature gets in, and what stays out
  2. History — from Gofer to this tree