X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FIOEnv.hs;fp=compiler%2Futils%2FIOEnv.hs;h=a87413b347c09a61349e81a697c967ad3cf04859;hb=7018caf5ea3319d575823641d03e172b85ea8791;hp=fc513a0ad666831bcf06af7f07bd4e0f9b4db419;hpb=0119f79bcf069823e4b49292934f682f680ceb90;p=ghc-hetmet.git diff --git a/compiler/utils/IOEnv.hs b/compiler/utils/IOEnv.hs index fc513a0..a87413b 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 []