
10 Dec
2004
10 Dec
'04
11:35 a.m.
Jules Bean wrote:
On 10 Dec 2004, at 15:34, Robert Dockins wrote:
So it should get "flattened," but it still doesn't run in constant space because the "x" parmeter isn't strict, so it will accumulate a bunch of closures like (((((((0)+1)+1)+1)+1)+1).... To make it strict, do something like this:
Isn't this what the strictness analyser is for? Doesn't GHC know that + for Int is strict in both arguments, and therefore it shouldn't accumulate a great big thunk like that?
It doesn't know that about (+) :: Num a => a -> a -> a. The original poster's code didn't mention Int anywhere, so GHC probably had to assume the worst. -- Ben