11

Is there options, except -O0, that can speed up compilation time?

It's not matter if resulting programs will be not optimised. Actually I want to just type-check large haskell package often and fast.

Flag -fno-code dramatically speeds up compilation but it's not possible to use it because TemplateHaskell is used by this program.

Fedor Gogolev
  • 10,391
  • 4
  • 30
  • 36
  • 2
    If you don't change many modules between compiles, and keep the object and interface files around, there should be not too many modules that need to be recompiled in each cycle. Is that not good enough? – Daniel Fischer Mar 27 '13 at 15:49
  • Actually not, because most part of this project is generated via TH in single(last in compilation order) module. – Fedor Gogolev Mar 27 '13 at 15:58
  • 1
    Urk. In that case, I have no idea how you could speed it up. – Daniel Fischer Mar 27 '13 at 16:02
  • 1
    Is it the TH generation that takes a long time, or recompiling the generated code? If the former, can you cache the generated file while developing? – strager Mar 27 '13 at 16:23
  • 3
    Since TH runs in GHCi, you might have better luck actually generating source from your TH, then compiling that with GHC. So split your TH into two phases. Essentially, using TH as a compiler to translate Haskell to Haskell. – Don Stewart Mar 27 '13 at 17:10
  • I assume you've read [this section in the GHC manual](http://www.haskell.org/ghc/docs/latest/html/users_guide/sooner-faster-quicker.html#sooner). Have you played with the memory settings for GHC itself? – yatima2975 Mar 27 '13 at 17:20
  • 1
    This might be of help: http://www.haskell.org/ghc/docs/7.6.2/html/users_guide/sooner-faster-quicker.html#sooner – Mikhail Glushenkov Mar 27 '13 at 20:12

2 Answers2

6

Looks like a task for hdevtools! Hdevtools is used to as a backend for vim-plugin of the same name and it provides speedy syntax and type checking, directly from the editor. It is about as fast as ghci when reloading modules. I assume that it can be used from the command line.

Another alternative would be to keep a ghci instance running and use that to type check your modules.

aleator
  • 4,436
  • 20
  • 31
  • 1
    Thanks, hdevtools is great! It's a little easier to use it instead of ghci. Unfortunately hdevtools does not work with cabal and cabal-dev, but it's possible to pass necessary ghc options. – Fedor Gogolev Mar 27 '13 at 22:22
  • Yeah. Having to pass options to make it work with cabal-dev is bit annoying, but this seems to be a common 'feature' with such tools. – aleator Mar 28 '13 at 04:46
2

I've found splitting up large files can speed up compilation.

Jonathan Fischoff
  • 1,467
  • 12
  • 22