Matt Green
Matt Green

Reputation: 2092

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

Upvotes: 2

Views: 303

Answers (2)

Matt Green
Matt Green

Reputation: 2092

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.

Upvotes: 0

ErikR
ErikR

Reputation: 52039

Can you post your .cabal file?

If I understand your situation correctly, here's how I might proceed:

  1. Verify that the alex and happy generated files are causing the slowdown.
  2. If that is the case, consider moving them into a different package so that ghci will load the compiled versions of them.

For #1, I might try replacing the alex and happy generated files with just stubs - skeletal files which contain definitions (= undefined) for only the symbols which are imported by other modules.

Upvotes: 2

Related Questions