Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
List reexports from extra
Documentation
firstJust :: (a -> Maybe b) -> [a] -> Maybe b #
Find the first element of a list for which the operation returns Just
, along
with the result of the operation. Like find
but useful where the function also
computes some expensive information that can be reused. Particular useful
when the function is monadic, see firstJustM
.
firstJust id [Nothing,Just 3] == Just 3 firstJust id [Nothing,Nothing] == Nothing