David Benbennick | 22 Dec 09:15
Picon

Re: Why does this blow the stack?

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

Gmane