Speed up compilation in GHC
Asked Answered
L

2

12

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.

Lipsey answered 27/3, 2013 at 15:40 Comment(7)
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?Novelistic
Actually not, because most part of this project is generated via TH in single(last in compilation order) module.Lipsey
Urk. In that case, I have no idea how you could speed it up.Novelistic
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?Biron
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.Enigmatic
I assume you've read this section in the GHC manual. Have you played with the memory settings for GHC itself?Earache
This might be of help: haskell.org/ghc/docs/7.6.2/html/users_guide/…Gokey
A
7

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.

Alejandro answered 27/3, 2013 at 17:48 Comment(2)
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.Lipsey
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.Alejandro
T
2

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

Turnout answered 27/3, 2013 at 16:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.