Proposal: Add filterM or filterA to Data.Sequence

David Feuer david.feuer at
Sun Dec 28 05:22:49 UTC 2014

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)
    go x r = f <$> p x <*> r
        f flg ys = if flg then x <| ys else ys

Bikeshed all you like over the name.

More information about the Libraries mailing list