
3 Apr
2008
3 Apr
'08
5:34 p.m.
olivier.boudry:
Hi all,
If you compile and run this:
main = do putStrLn $ show $ take (last [0..]) [0..]
or simply run:
take (last [0..]) [0..]
in ghci, it first hang for about one minute and then starts to generate an infinite list. I was expecting "last [0..]" to never produce a value and the "take" function to never take from the [0..] list.
I can't reproduce this with ghc 6.8.2 on a 64 bit arch, both just sit running in constant space, at full cpu. Are you perhaps constraining it to an Int type somewhere (so that [0..] terminates at maxBound)? I.e. this kind of thing: Prelude> last [1..] :: Int8 127 but for maxBound on Int32? -- Don