Stricter enumFrom instance for Integer, to match Int
A common source of user complaints are code like the following failing:
main = print (head (drop 1000000 [1 .. ])) Stack space overflow: current size 8388608 bytes. Use `+RTS -Ksize' to increase it.
Due to a lazy accumulator in enumFrom for Integer. While the following are all fine:
main = print (head (drop 1000000 [1 .. 100000000000000]))
(enumFromTo is strict enough on Integer), and:
main = print (head (drop 1000000 [(1::Int) .. ]))
(Int has had a strict accumulator for enumFrom since 1994.)
"Atomic" strictness on Num operations for Int is fairly consistent through the base libraries (e.g. length, take, maximum), however for Integer it is ad hoc. maximum, for example, has a strict instance for Integer, but as we see here, enumFrom is still so lazy it fails.
This patch adds a strict accumulator to Integer's enumFrom, and makes the suggestion we in future ensure Num operations on Integer in the base library behave as strict as Int instances.
-enumDeltaInteger x d = x : enumDeltaInteger (x+d) d +enumDeltaInteger x d = x `seq` x : enumDeltaInteger (x+d) d