filter p xs = [ x | x <- xs, p x]
>>> filter odd [1, 2, 3] [1,3]
filter (> "a") (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" filter (> "x") (fromList [(5,"a"), (3,"b")]) == empty filter (< "a") (fromList [(5,"a"), (3,"b")]) == empty
ghci> Streams.fromList ["the", "quick", "brown", "fox"] >>= Streams.filter (/= "brown") >>= Streams.toList ["the","quick","fox"]
>>> filter even (fromList [("C",3),("B",2),("A",1)]) fromList [("B",2)] >>> filter odd (fromList [("C",3),("B",2),("A",1)]) fromList [("C",3),("A",1)]
>>> filter (`notElem` ['a','e','i','o','u']) "You don't need vowels to convey information!" "Y dn't nd vwls t cnvy nfrmtn!"
filter (const False) t == ""
filter (const True) t == t
length (filter p t) <= length t
filter p t == pack [ c | c <- unpack t, p c ]