ghc: out of memory error while compiling huge "let"

Neil Mitchell ndmitchell at
Fri Jan 12 12:47:21 EST 2007

Hi David,

I found that GHC is O(n^2) in terms of the number of lines in a do
block, so by splitting up a huge 1000 line do block in to 10 x 100
line do blocks, I was able to get a massive compile time boost.
Perhaps you might have similar luck with let's.

If you do, report a bug!



On 1/12/07, David Morse <dcmorse at> wrote:
> I have a machine-generated source-code file that brings my computer to
> its knees with ghc-6.6.  After an hour or so of rummaging around, ghc
> dies with: "ghc-6.6: out of memory (requested 1048576 bytes)".  The
> linux machine has 1gb RAM and 2gb swap, and I don't have access to a
> better one.
> The file is of the form
> -------------------------------------------
> module foo (a,b) where
> (a,b) = let ...10,300 bindings... ; in ([a1,a2,a3...a300],[b1,b2,b3...b10000])
> --------------------------------------------
> Is there some simple syntactic refactoring I can do to make this work?
>  E.g. busting the local bindings out of the "let" and into to the
> global level?
> The bindings are intertwined, but I could (with some effort) reorder
> them so that b5000 would only reference b5001...b10000 and never
> b1...b4999.
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at

More information about the Glasgow-haskell-users mailing list