Re: Re[2]: [GHC] #876: stack overflow on 'length . filter odd $ [0.. 999999999]'

2006-09-01 Thread Jan-Willem Maessen
On Aug 31, 2006, at 3:03 PM, Simon Peyton-Jones wrote: (replying to me) | Actually, it's sufficient to do good arity-raising transformations, | and use the definition: |foldl f z xs = foldr (\x k a - k (f a x)) id xs z | | This yields code which looks a bit like this: | ... Absolutely

Re: Re[2]: [GHC] #876: stack overflow on 'length . filter odd $ [0 .. 999999999]'

2006-09-01 Thread Duncan Coutts
On Thu, 2006-08-31 at 11:29 +0100, Malcolm Wallace wrote: Bulat Ziganshin [EMAIL PROTECTED] wrote: It makes sense to me that the above behaviour is seen: length is now a good consumer, but it generates 1+(1+(1+(1+... as it is consuming, and this causes a stack overflow. I don't

Re: Re[2]: [GHC] #876: stack overflow on 'length . filter odd $ [0 .. 999999999]'

2006-08-31 Thread Malcolm Wallace
Bulat Ziganshin [EMAIL PROTECTED] wrote: It makes sense to me that the above behaviour is seen: length is now a good consumer, but it generates 1+(1+(1+(1+... as it is consuming, and this causes a stack overflow. I don't think we can fix this while staying with fold/build fusion,

RE: Re[2]: [GHC] #876: stack overflow on 'length . filter odd $ [0.. 999999999]'

2006-08-31 Thread Simon Peyton-Jones
| Actually, it's sufficient to do good arity-raising transformations, | and use the definition: |foldl f z xs = foldr (\x k a - k (f a x)) id xs z | | This yields code which looks a bit like this: | | let loop [] = id | loop (x:xs) = let k = loop xs in (\a - k (f a x)) | in loop xs z