Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to start reading GHC's source code

Tags:

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?

like image 980
Dan Avatar asked Sep 04 '12 18:09

Dan


People also ask

How do I run a GHC file?

Open a command window and navigate to the directory where you want to keep your Haskell source files. Run Haskell by typing ghci or ghci MyFile. hs. (The "i" in "GHCi" stands for "interactive", as opposed to compiling and producing an executable file.)

How do I use Haskell GHC?

If you have installed the Haskell Platform, open a terminal and type ghci (the name of the executable of the GHC interpreter) at the command prompt. Alternatively, if you are on Windows, you may choose WinGHCi in the Start menu. And you are presented with a prompt. The Haskell system now attentively awaits your input.


2 Answers

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.

like image 53
C. A. McCann Avatar answered Sep 28 '22 09:09

C. A. McCann


The GHC commentary is a good place to start.

like image 33
hammar Avatar answered Sep 28 '22 07:09

hammar