:: Monad m => (a -> m Bool) -> [a] -> m (Maybe a) -package:monadlist

Like find, but where the test can be monadic.
findM (Just . isUpper) "teST"             == Just (Just 'S')
findM (Just . isUpper) "test"             == Just Nothing
findM (Just . const True) ["x",undefined] == Just (Just "x")
return the first value from a list, if any, satisfying the given predicate.
Like find, but takes a monadic function instead; retains the short-circuiting behaviour of the non-monadic version. For example,
findM (\a -> putStr (show a <> " ") >> pure False) [1..10]
would print "1 2 3 4 5 6 7 8 9 10" and return Nothing, while
findM (\a -> putStr (show a <> " ") >> pure True) [1..10]
would print "1" and return Just 1.
A generalization of findM to Foldable instances.