groupBy really does not do what you want; even if it accepts several predicate functions, it does not perform filtering in the list. It simply groups continuous sequences of list items that satisfy a certain condition. Even if your filter conditions, when combined, cover all the elements in the attached list, this is still a different operation. For example, groupBy will not reorder list items, nor will it be able to include this item more than once in the result, while your operation can do both of these things.
This function will do what you are looking for:
import Control.Applicative filterMulti :: [a -> Bool] -> [a] -> [[a]] filterMulti ps as = filter <$> ps <*> pure as
As an example:
> filterMulti [(<2), (>=5)] [2, 5, 1, -2, 5, 1, 7, 3, -20, 76, 8] [[1, -2, 1, -20], [5, 5, 7, 76, 8]]
source share