[Haskell-cafe] Why does this blow the stack?

David Benbennick dbenbenn at gmail.com
Sat Dec 22 03:15:46 EST 2007


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:

Prelude> length $ take 10 ([undefined ..] :: [Integer])
10

With his patch, that will throw.

Some other types have the same issue (lazy Enum when it could be
strict, leading to stack overflow):

Prelude> length $ take 10 ([undefined ..] :: [Double])
10
Prelude> length $ take 10 ([undefined ..] :: [Float])
10
Prelude Foreign.C.Types> length $ take 10 ([undefined ..] :: [CFloat])
10
Prelude Foreign.C.Types> length $ take 10 ([undefined ..] :: [CDouble])
10
Prelude Foreign.C.Types> length $ take 10 ([undefined ..] :: [CLDouble])
10
Prelude Data.Ratio> length $ take 10 ([undefined ..] :: [Ratio Int])
10


More information about the Haskell-Cafe mailing list