any package:relude

Determines whether any element of the structure satisfies the predicate.

Examples

Basic usage:
>>> any (> 3) []
False
>>> any (> 3) [1,2]
False
>>> any (> 3) [1,2,3,4,5]
True
>>> any (> 3) [1..]
True
>>> any (> 3) [0, -1..]
* Hangs forever *
Boolean monoid under disjunction (||).
Any x <> Any y = Any (x || y)

Examples

>>> Any True <> mempty <> Any False
Any {getAny = True}
>>> mconcat (map (\x -> Any (even x)) [2,4,6,7,8])
Any {getAny = True}
>>> Any False <> mempty
Any {getAny = False}
Monadic version of any.
>>> anyM (readMaybe >=> pure . even) ["5", "10"]
Just True

>>> anyM (readMaybe >=> pure . even) ["10", "aba"]
Just True

>>> anyM (readMaybe >=> pure . even) ["aba", "10"]
Nothing
Zero or more.

Examples

>>> many (putStr "la")
lalalalalalalalala... * goes on forever *
>>> many Nothing
Just []
>>> take 5 <$> many (Just 1)
* hangs forever *
Note that this function can be used with Parsers based on Applicatives. In that case many parser will attempt to parse parser zero or more times until it fails.
Determines whether any element of the structure satisfies its appropriate predicate argument. Empty structures yield False.

Examples

Basic usage:
>>> biany even isDigit (27, 't')
False
>>> biany even isDigit (27, '8')
True
>>> biany even isDigit (26, 't')
True
>>> biany even isDigit (Left 27)
False
>>> biany even isDigit (Left 26)
True
>>> biany even isDigit (BiList [27, 53] ['t', '8'])
True
Empty structures yield False:
>>> biany even isDigit (BiList [] [])
False