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
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
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,
| 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