
24 Oct
2006
24 Oct
'06
12:19 p.m.
Hello Simon, Tuesday, August 8, 2006, 4:18:01 PM, you wrote:
-filterM _ [] = return [] -filterM p (x:xs) = do - flg <- p x - ys <- filterM p xs - return (if flg then x:ys else ys)
The new definition looks less lazy than the original, so it's not a drop-in replacement. Also, we would need some measurements to test whether this version doesn't lose efficiency - it probably fuses better, but might be slower when it doesn't fuse. Rules to turn the foldr version back into the recursive version might be needed (or aggressive inlining).
jfyi - original filterM isn't tail recursive, so it overflows stack on really large data. -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com