
On 11/13/2010 08:55 AM, Petr Prokhorenkov wrote:
import Data.List
wtf d = head . dropWhile (< 10^100) . map (*d) $ enumFrom 2
main = do print $ wtf 1 print $ wtf 2 -- Everything is ok without this line
Is there any way to overcome this?
I think this phenomenon is called the "full laziness transform": an optimization that GHC will apply to avoid redundant computation. More details in: "Let-Floating: Moving Bindings to Give Faster Programs" http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.30.9079 So I think you're seeing bug http://hackage.haskell.org/trac/ghc/ticket/917 where the increased sharing only leads to space leaks. You could try the workaround, passing -fno-full-laziness (it might need to come after -O on the command line). I'm not sure if this'd be more or less fragile than disabling inlining as Felipe suggested. I'd also suggest adding yourself as a CC: on bug 917 so GHC HQ knows how many people are being affected by this kind of behavior. Hope this helps, -Brian