
23 Apr
2010
23 Apr
'10
10:44 a.m.
On April 22, 2010 21:11:55 Roman Leshchinskiy wrote:
That doesn't really help me, though, because I can't tell why using foldl as opposed to foldl' is essential (or even correct) in these cases. In fact, at a cursory glance a lot of them look quite leaky to me.
Here's a toy example where replacing foldl with foldl' would be wrong sumWhile g y x | g x = y + x | otherwise = 0 foldl (sumWhile (< 3)) 6 [5,undefined,4,3,2,1,0] Perhaps there is other code where forcing values via foldl' before they are known to be required can be bad (due the cost or causing an exception). Cheers! -Tyson