I’ve started playing around with Haskell again and since I’m doing so on a new machine I don’t have a copy of the language source code.
I wanted to rectify that situation but my Google fu was weak and it took me way too long to figure out how to get it so I thought I’d better document it for future me.
The easiest way is to clone the copy of the GHC repository on github:
git clone https://github.com/ghc/ghc.git
Initially that doesn’t have any of the code for the core libraries but running the following command (which takes ages!) sorts it out:
cd ghc ./sync-all get
Noticing that the core libraries weren’t there initially I thought I must have done something wrong so I went to the documentation for the function that I wanted to see the source for – getAssocs.
Most of the base packages are available from the Haskell darcs repository so I ended up cloning the ones I wanted in the time that it took for the sync-all script to run.
darcs get http://darcs.haskell.org/packages/base/ # gets most of the packages we'd be interested in darcs get http://darcs.haskell.org/packages/array/ # gets the array package
Of course I could have just been patient and waited for the script to finish…