Making GHCi scale better and faster

From HaskellWiki

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.

You can do so like so:

$ ghci -fobject-code

Or in ghci itself:

:set -fobject-code

If you want it on all the time, you can put the above line in a .ghci file either in your home directory or in the directory of your project.

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.