[Haskell-cafe] Filter by several predicates at once

Isaac Dupree isaacdupree at charter.net
Thu Jan 17 09:46:20 EST 2008


Neil Mitchell wrote:
> Hi
> 
>>> passall, passany :: [a -> Bool] -> a -> Bool
>>> passall ps v = and $ map ($v) ps
>>> passany ps v = or $ map ($v) ps
>> or something similar defined anywhere? Such that one can write

nearly; using Prelude:
passall ps v = all ($v) ps
passany ps v = any ($v) ps

> One thing I have often wanted is something like:
> 
> or1 a b x = a x || b x
> or2 a b x y = a x y || b x y

yep, there's the idea of putting Bools in a typeclass that allows you to 
(||) functions-returning-Bool-class-instance for example, which I 
haven't used much but seems like a good idea (though potentially 
confusing, especially if the Prelude-Bool-specific names are reused)

~Isaac


More information about the Haskell-Cafe mailing list