[Haskell-cafe] RE: simple function: stack overflow in hugsvsnonein ghc

Claus Reinke claus.reinke at talk21.com
Tue Sep 25 07:36:55 EDT 2007


> return (replicate 1000000 'a') >>= \x->print $ spant (const True) x
> 
> ERROR - Garbage collection fails to reclaim sufficient space
> 
> i.e. as the function unfold, the thunk representing the second term builds 
> up on the heap. (not sure why it works for an infinite list, hugs must drop 
> the reference to the tail ?)

actually, that works because the infinite list has a finite representation,
being cyclic, so there's nothing to unfold:

>>>>>return (repeat 'a') >>= \ x -> print $ span (const True) x

claus



More information about the Haskell-Cafe mailing list