Commit c2be0834 authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Add orM from monad-loops



...a monadic short-circuit version of 'or'.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarNiklas Hambuechen <niklash@google.com>
parent 6f160319
......@@ -37,6 +37,7 @@ module Ganeti.Utils.Monad
, retryMaybeN
, anyM
, allM
, orM
) where
import Control.Monad
......@@ -62,3 +63,7 @@ anyM p = foldM (\v x -> if v then return True else p x) False
-- | Short-circuit 'all' with a monadic predicate.
allM :: (Monad m) => (a -> m Bool) -> [a] -> m Bool
allM p = foldM (\v x -> if v then p x else return False) True
-- | Short-circuit 'or' for values of type Monad m => m Bool
orM :: (Monad m) => [m Bool] -> m Bool
orM = anyM id
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment