filter p xs = [ x | x <- xs, p x]
>>> filter odd [1, 2, 3] [1,3]
>>> filter (\l -> length l > 3) ["Hello", ", ", "World", "!"] ["Hello","World"]
>>> filter (/= 3) [1, 2, 3, 4, 3, 2, 1] [1,2,4,2,1]
filter p xs = [ x | x <- xs, p x]
>>> filter odd [1, 2, 3] [1,3]
filter (pure True) = cat filter (liftA2 (&&) p1 p2) = filter p1 >-> filter p2 filter f = mapMaybe (\a -> a <$ guard (f a))
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 ]