Making GHCi scale better and faster

From HaskellWiki
Revision as of 06:59, 9 December 2013 by Chrisdone (talk | contribs) (First version)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A common complaint with GHCi is that it doesn’t scale well when the size of the project gets bigger. Once you hit 20, 30, 50, or 150 modules, it stops being fun anymore and you start wishing you didn’t have to wait for it to load.

I recommend enabling -fobject-code. This makes GHCi compile everything once and then use incremental recompilation thereafter. You’ll find that you can load 100-module projects and work with them just fine in this way.

After that, you may notice that loading some modules gives less type information and general metadata than before. For that, re-enable byte-compilation temporarily with -fbyte-code and :load that module again, you now have fast recompilation with complete information, too.

Another tip is to use -fno-code to have really fast compilation. This also works in combination with -fobject-code. But I’d recommend using this only for type checking, not for getting useful warnings (like pattern match inexhaustiveness). So I would combine it with -fobject-code in the same way as above with -fbyte-code, and then once you’re done hacking, re-enable -fobject-code and rebuild everything.