summaryrefslogtreecommitdiff
path: root/compiler/utils/IOEnv.hs
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2007-10-27 15:45:51 +0000
committersimonpj@microsoft.com <unknown>2007-10-27 15:45:51 +0000
commit7018caf5ea3319d575823641d03e172b85ea8791 (patch)
tree9f2e7fc8901fb3ecb234eaf85c42086243facc08 /compiler/utils/IOEnv.hs
parent0119f79bcf069823e4b49292934f682f680ceb90 (diff)
downloadhaskell-7018caf5ea3319d575823641d03e172b85ea8791.tar.gz
Add anyM to IOEnv
Diffstat (limited to 'compiler/utils/IOEnv.hs')
-rw-r--r--compiler/utils/IOEnv.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/utils/IOEnv.hs b/compiler/utils/IOEnv.hs
index fc513a0ad6..a87413b347 100644
--- a/compiler/utils/IOEnv.hs
+++ b/compiler/utils/IOEnv.hs
@@ -17,7 +17,7 @@ module IOEnv (
-- Standard combinators, specialised
returnM, thenM, thenM_, failM, failWithM,
mappM, mappM_, mapSndM, sequenceM, sequenceM_,
- foldlM, foldrM,
+ foldlM, foldrM, anyM,
mapAndUnzipM, mapAndUnzip3M,
checkM, ifM, zipWithM, zipWithM_,
@@ -176,6 +176,7 @@ mapAndUnzipM :: (a -> IOEnv env (b,c)) -> [a] -> IOEnv env ([b],[c])
mapAndUnzip3M :: (a -> IOEnv env (b,c,d)) -> [a] -> IOEnv env ([b],[c],[d])
checkM :: Bool -> IOEnv env a -> IOEnv env () -- Perform arg if bool is False
ifM :: Bool -> IOEnv env a -> IOEnv env () -- Perform arg if bool is True
+anyM :: (a -> IOEnv env Bool) -> [a] -> IOEnv env Bool
mappM f [] = return []
mappM f (x:xs) = do { r <- f x; rs <- mappM f xs; return (r:rs) }
@@ -186,6 +187,10 @@ mapSndM f ((a,b):xs) = do { c <- f b; rs <- mapSndM f xs; return ((a,c):rs) }
mappM_ f [] = return ()
mappM_ f (x:xs) = f x >> mappM_ f xs
+anyM f [] = return False
+anyM f (x:xs) = do { b <- f x; if b then return True
+ else anyM f xs }
+
zipWithM :: (a -> b -> IOEnv env c) -> [a] -> [b] -> IOEnv env [c]
zipWithM f [] bs = return []
zipWithM f as [] = return []