Proposal: Add filterM or filterA to Data.Sequence

Andreas Abel andreas.abel at ifi.lmu.de
Mon Dec 29 10:52:33 UTC 2014


+1

On 28.12.2014 06:22, David Feuer wrote:
> This can be given exactly the same implementation as the one for lists:
>
> filterM :: (Applicative f) => (a -> f Bool) -> Seq a -> f (Seq a)
> filterM p = foldr go (pure empty)
>    where
>      go x r = f <$> p x <*> r
>        where
>          f flg ys = if flg then x <| ys else ys
>
>
> Bikeshed all you like over the name.


-- 
Andreas Abel  <><      Du bist der geliebte Mensch.

Department of Computer Science and Engineering
Chalmers and Gothenburg University, Sweden

andreas.abel at gu.se
http://www2.tcs.ifi.lmu.de/~abel/


More information about the Libraries mailing list