From e19dc8554723a148e6b809da4989a747f3aa925e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 2 Dec 2011 16:10:52 -0400 Subject: factor out untilTrue --- Utility/Conditional.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Utility') 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 -- cgit v1.2.3