summaryrefslogtreecommitdiff
path: root/src/Util.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Util.hs')
-rw-r--r--src/Util.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Util.hs b/src/Util.hs
index 4200e20..faf18af 100644
--- a/src/Util.hs
+++ b/src/Util.hs
@@ -9,3 +9,9 @@ uniqOn :: Eq b => (a -> b) -> [a] -> [a]
uniqOn f (x:y:xs) | f x == f y = uniqOn f (x:xs)
| otherwise = x : uniqOn f (y:xs)
uniqOn _ xs = xs
+
+andM :: (Foldable t, Monad m) => t (m Bool) -> m Bool
+andM = foldr (\a b -> a >>= \case True -> b; False -> return False) (return True)
+
+allM :: (Foldable t, Monad m) => (a -> m Bool) -> t a -> m Bool
+allM f = foldr (\a b -> f a >>= \case True -> b; False -> return False) (return True)