My program reads a xls file and creates a haskell program that does exactly the same as what the xls does. Every cell in the xls is a function and contains 2 lines:

the type declaration and 1 line the implementation. The type of a cell is XlsCell.

data XlsCell = Reader ExternalCells XlsCellRes

data XlsCellRes = XlsCellString String | XlsCellBool Bool | .....

type ExternalCells = Map String XlsCellRes   -- search (or set) a value of a cell by its name.

The externalCells are for the cells you can change at runtime.

The generated program was first 30000 lines. When I compiled it with ghc 7.8.3. -O0 the program worked, but was terribly slow. With -O2 I got: out of memory.

With a few trics the generated code is now split up in 2 files 5000 and 10000 lines. I've upgraded to ghc 7.8.4. If I do ghc -O2 the program takes more then 4 hours

to compile. The –O2 compilation is essential. The resulting program is much (more then 10x) faster then without –O2.

What can I do (changes in the generated code, changes to speed up ghc?) to make ghc faster with -O2? I tried ghc-make, but it doesn't make a big difference.

 

Kees