factor out untilTrue

This commit is contained in:
Joey Hess 2011-12-02 16:10:52 -04:00
parent fb68a7881f
commit e19dc85547
4 changed files with 29 additions and 38 deletions

View file

@ -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