darcs patch: Improve Control.Monad.filterM:
Bulat Ziganshin
bulat.ziganshin at gmail.com
Tue Oct 24 08:19:29 EDT 2006
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 at gmail.com
More information about the Libraries
mailing list