filter -package:Cabal -package:containers -package:hedgehog package:io-streams

Drops chunks from an input stream if they fail to match a given filter predicate. See filter. Items pushed back to the returned stream are propagated back upstream. Example:
ghci> Streams.fromList ["the", "quick", "brown", "fox"] >>=
Streams.filter (/= "brown") >>= Streams.toList
["the","quick","fox"]
Drops chunks from an input stream if they fail to match a given filter predicate. See filter. Items pushed back to the returned stream are propagated back upstream. Example:
ghci> Streams.fromList ["the", "quick", "brown", "fox"] >>=
Streams.filterM (return . (/= "brown")) >>= Streams.toList
["the","quick","fox"]
Filters output to be sent to the given OutputStream using a pure function. See filter. Example:
ghci> import qualified Data.ByteString.Char8 as S
ghci> os1 <- Streams.stdout >>= Streams.'System.IO.Streams.unlines
ghci> os2 <- os1 >>= Streams.contramap (S.pack . show) >>= Streams.filterOutput even
ghci> Streams.write (Just 3) os2
ghci> Streams.write (Just 4) os2
4
Filters output to be sent to the given OutputStream using a predicate function in IO. See filterM. Example:
ghci> let check a = putStrLn a ("Allow " ++ show a ++ "?") >> readLn :: IO Bool
ghci> import qualified Data.ByteString.Char8 as S
ghci> os1 <- Streams.unlines Streams.stdout
ghci> os2 <- os1 >>= Streams.contramap (S.pack . show) >>= Streams.filterOutputM check
ghci> Streams.write (Just 3) os2
Allow 3?
False<Enter>
ghci> Streams.write (Just 4) os2
Allow 4?
True<Enter>
4