darcs patch: Improve Control.Monad.filterM:

Simon Marlow simonmarhaskell at gmail.com
Wed Aug 9 06:41:48 EDT 2006

Spencer Janssen wrote:
> On Aug 8, 2006, at 10:24 AM, Simon Marlow wrote:
>> It may well be better, but it doesn't have the same laziness  
>> properties, so it isn't the same function.  eg. try this:
>>  do filterM (\x -> return undefined) [1]; return ()
> Ah yes, I missed that.
>> Of course we may discuss whether the extra laziness is useful, but  I 
>> can't apply the patch as it stands because it would break Haskell  98.
> Data.List uses "#ifdef USE_REPORT_PRELUDE" in places to choose  between 
> original and improved implementations.  Is that an option in  this case?

Not really, we don't want to have two versions of the base package.  The 
USE_REPORT_PRELUDE code is there mainly for documentation, I don't believe it 
has actually worked for a long time now.

We could have Control.Monad.filterM be different from Monad.filterM to avoid 
breaking Haskell 98, if there was a convincing enough argument that the 
semantics of Monad.filterM should be changed.

Library functions usually strive to be as lazy as possible, because laziness 
can't be recovered if you need it.  On the other hand, laziness might imply 
unfixable space or time leaks in library code, so it's a delicate balance.


More information about the Libraries mailing list