Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Speed up compilation in GHC

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.

like image 441
Fedor Gogolev Avatar asked Mar 27 '13 15:03

Fedor Gogolev


People also ask

Why does Haskell take so long to compile?

The reason it takes so long is that there's a lot of redundant recomputation, and the intermediate results are not memoized. Just what we need to see how well GHC can do the same thing at compile time.

How do I make Haskell faster?

Also, instead of dealing with machine data types, you make algebraic data types all the time. Weirdest of all though is higher order functions. You would think that creating functions on the fly, and throwing them around, would make a program slower. But using higher order functions actually makes Haskell faster.

Is GHCi an interpreter?

This library offers interfaces which mediate interactions between the ghci interactive shell and iserv , GHC's out-of-process interpreter backend.

What does Haskell compile to?

Unlike Python, Ruby, JavaScript, Lua, and other interpreted languages, Haskell is compiled ahead-of-time, directly to native machine code.


2 Answers

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.

like image 158
aleator Avatar answered Oct 16 '22 08:10

aleator


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

like image 33
Jonathan Fischoff Avatar answered Oct 16 '22 08:10

Jonathan Fischoff