diff options
author | Joey Hess <joey@kitenet.net> | 2011-12-02 16:10:52 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-12-02 16:12:31 -0400 |
commit | e19dc8554723a148e6b809da4989a747f3aa925e (patch) | |
tree | e55363162c701f5250beae46323aa8e0a1a65ccb /Utility | |
parent | fb68a7881f725a7b097f8b0f1b347f24dfea5d59 (diff) |
factor out untilTrue
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/Conditional.hs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Utility/Conditional.hs b/Utility/Conditional.hs index 85e39ec64..7a0df4b48 100644 --- a/Utility/Conditional.hs +++ b/Utility/Conditional.hs @@ -9,6 +9,12 @@ module Utility.Conditional where import Control.Monad (when, unless) +untilTrue :: Monad m => [v] -> (v -> m Bool) -> m Bool +untilTrue [] _ = return False +untilTrue (v:vs) a = do + ok <- a v + if ok then return ok else untilTrue vs a + whenM :: Monad m => m Bool -> m () -> m () whenM c a = c >>= flip when a |