Search code examples
haskellcabal

cabal repl is too slow


Currently, cabal repl is unusable for me. Typing at the prompt is erratic: a few letters appear, then it seems to hang for 5-10 seconds, only to proceed again afterwards. I suspect it's related to the fact that it loads Alex/Happy generated files (81K and 134K respectively) into the REPL. I don't really need those files for REPL support most of the time. I'm not sure if that's actually the problem, but I don't know what else to try.

I'd like to be able to exclude them from the REPL while still including them in the build process. Even better: can I only use one function from each of those files (lex/parse) somehow?

Edit: I'm seeing this behavior with GHC 7.8.3/Cabal 1.20.0.3 running on OS X 10.9 and a mid-2012 rMBP (Sandy Bridge) with 16GB of RAM. GHC/Cabal was installed via Homebrew.

Edit 2: Cabal file in question


Solution

  • I tried reorganizing the code per user5402's answer, but I wasn't able to get much of a speedup, even with code in different base packages.

    Instead, I created a .ghci file in the project directory with the following contents:

    :set -fobject-code
    

    This loaded compiled versions of modules, with only the exported functions callable. For my uses, this is fine.