Dan
Dan

Reputation: 13170

Where to start reading GHC's source code

I'm trying to learn how various aspects of GHC, like type inference, pattern matching, and other code transformations, are implemented.

However the codebase is fairly large and the file names use a lot of acronyms (simpl, stg, stranal...). What do these mean, and how is the code organized?

Upvotes: 23

Views: 711

Answers (2)

C. A. McCann
C. A. McCann

Reputation: 77404

As hammar says, the GHC commentary is probably the best place to start for learning about GHC itself. This does assume some prior knowledge of compilers in general, but if your primary interest is in modifying GHC you can probably get by with just a basic CS background.

If you're interested more generally in the principles behind GHC, e.g. if you want to learn how to write your own compiler, you'd probably be better served by perusing Simon Peyton-Jones' myriad publications on relevant topics, including an entire book on implementing functional languages and a "tutorial" book that goes through the implementation of a non-strict functional language.

Upvotes: 11

hammar
hammar

Reputation: 139900

The GHC commentary is a good place to start.

Upvotes: 8

Related Questions