Add allM and anyM functions.
authorMatthijs Kooijman <matthijs@stdin.nl>
Wed, 7 Apr 2010 12:15:22 +0000 (14:15 +0200)
committerMatthijs Kooijman <matthijs@stdin.nl>
Wed, 7 Apr 2010 12:15:22 +0000 (14:15 +0200)
cλash/CLasH/Utils.hs

index 41d7beee98a635083b2ad0c66d7aedbfc9403c46..2966757a038b1d2fefd6a9db51547a0bcf8d0bff 100644 (file)
@@ -48,6 +48,12 @@ andM, orM :: (Monad m) => m [Bool] -> m Bool
 andM = Monad.liftM and
 orM = Monad.liftM or
 
+-- | Monadic versions of any and all. We reimplement them, since there
+-- is no ready-made lifting function for them.
+allM, anyM :: (Monad m) => (a -> m Bool) -> [a] -> m Bool
+allM f = andM . (mapM f)
+anyM f = orM . (mapM f)
+
 mapAccumLM :: (Monad m) => (acc -> x -> m (acc, y)) -> acc -> [x] -> m (acc, [y])
 mapAccumLM _ s []        =  return (s, [])
 mapAccumLM f s (x:xs)    =  do