Space leak question

Bertram Felgenhauer bertram.felgenhauer at
Thu Jul 28 11:18:45 CEST 2011

Hi Will,

Will Ness wrote:
> Will Ness <will_n48 <at>> writes:
> > CORRECTION: just with "gaps" (but not the other ones), changing the "g" 
> > function from composed pieces into a "normal" code, it did it! (probably 
> > some ghc version-specific stuff at play):
> >
> >   g xs = 3 : gaps 5
> >               ( foldi (\(x:xs) -> (x:) . union xs)
> >                 [[x*x, x*x+2*x..] | x <- xs] )
> addition: with
>   gaps k xs = minus [k,k+2..] xs
> it also runs without the space leak, but with
>   gaps k = minus [k,k+2..]
> the leak reappears.

I'm not sure that I tried the same code as you did, but for me both
these versions were leaky. I cannot explain why, but I see that in the
resulting core (ghc ... -ddump-simpl) the [5,7..] list ends up as a top
level constant, despite -fno-full-laziness. So the cause of the space
leak remains the same -- the [5,7..] list is being shared among several
invocations of g. Tricky.


More information about the Glasgow-haskell-users mailing list