[Haskell-cafe] Why does this blow the stack?
David Benbennick
dbenbenn at gmail.com
Sat Dec 22 04:19:28 EST 2007
On 12/22/07, David Benbennick <dbenbenn at gmail.com> wrote:
> On 12/21/07, Stefan O'Rear <stefanor at cox.net> wrote:
> > Because they simply aren't the same.
>
> Good point; thanks. That means that Don's patch could theoretically
> break some existing Haskell program:
In fact, it's possible to get strictness to avoid stack overflow, and
still have laziness to allow undefined:
myEnumFrom :: Integer -> [Integer]
myEnumFrom a = map (a+) $ enumDeltaIntegerStrict 0 1 where
enumDeltaIntegerStrict x d = x `seq` x : enumDeltaIntegerStrict (x+d) d
then
*Main> (myEnumFrom 42) !! (10^6)
1000042
*Main> length $ take 10 $ myEnumFrom undefined
10
More information about the Haskell-Cafe
mailing list