Proposal: Add filterM or filterA to Data.Sequence

Milan Straka fox at ucw.cz
Tue Dec 30 22:41:23 UTC 2014


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.

Also, filterM is not yet settled in base, so we should wait some time
until it is.

Cheers,
Milan

PS: It is a shame we cannot reuse Foldable and/or Traversable for
filtering. Maybe we should add a new Filterable class?


More information about the Libraries mailing list