diff options
author | Joey Hess <joey@kitenet.net> | 2012-10-06 16:16:31 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-10-06 16:16:31 -0400 |
commit | dbf59167c40b112c78b4beeee3025eb2438a8f8e (patch) | |
tree | 9f39c8805944ef94a7b1045b9caae5be9617cd1d /Utility/Monad.hs | |
parent | c2017cd2f5d7a80d13c6f242f84a3eb7a6c9b576 (diff) |
look for sysctl in some common sbin locations when it's not in PATH
Diffstat (limited to 'Utility/Monad.hs')
-rw-r--r-- | Utility/Monad.hs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Utility/Monad.hs b/Utility/Monad.hs index 2c9b9e9e0..6abd7ee5d 100644 --- a/Utility/Monad.hs +++ b/Utility/Monad.hs @@ -16,6 +16,12 @@ firstM :: Monad m => (a -> m Bool) -> [a] -> m (Maybe a) firstM _ [] = return Nothing firstM p (x:xs) = ifM (p x) (return $ Just x , firstM p xs) +{- Runs the action on values from the list until it succeeds, returning + - its result. -} +getM :: Monad m => (a -> m (Maybe b)) -> [a] -> m (Maybe b) +getM _ [] = return Nothing +getM p (x:xs) = maybe (getM p xs) (return . Just) =<< p x + {- Returns true if any value in the list satisfies the predicate, - stopping once one is found. -} anyM :: Monad m => (a -> m Bool) -> [a] -> m Bool |