[Haskell-cafe] Why does this blow the stack?
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
*Main> (myEnumFrom 42) !! (10^6)
*Main> length $ take 10 $ myEnumFrom undefined
More information about the Haskell-Cafe