Proposal: Add filterM or filterA to Data.Sequence

Bardur Arantsson spam at scientician.net
Wed Dec 31 00:25:45 UTC 2014


On 2014-12-30 23:41, Milan Straka wrote:
> Hi all,
> 
>> -----Original message-----
>> From: David Feuer <david.feuer at gmail.com>
>> Sent: 30 Dec 2014, 13:15
>>
>> On Tue, Dec 30, 2014 at 12:05 PM, Johan Tibell <johan.tibell at gmail.com> wrote:
>>> We should check that `filterM . toList` isn't as fast. That was the case for
>>> bytestring and we rejected adding filterM there for that reason.
>>
>> Let me expand that definition to what it really looks like:
>>
>>   filterMSeq f = fmap fromList . filterM f . toList
>>
>> Yes, you can do this. Yes, it's probably even pretty efficient. But
>> it's a bit painful to have to expand things out like this just to
>> switch a bit of code from lists to sequences.
> 
> the problem with this is that there are really many functions that
> "would be useful", but we do not really want to add them all.
> 
> A general rule I have been using is "can this be implemented
> straightforwardly using existing methods without hurting performance
> much"? So I would like to see the numbers, please.
> 

Well, there's an opposing point called "usability". If there are already
"obvious" functions to use in other data structure modules then they
should *probably* also be represented in the other data structure modules.

(I don't claim that this is necessarily a "trump", but I think it bears
consideration.)

Regards,



More information about the Libraries mailing list