projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0119f79
)
Add anyM to IOEnv
author
simonpj@microsoft.com
<unknown>
Sat, 27 Oct 2007 15:45:51 +0000
(15:45 +0000)
committer
simonpj@microsoft.com
<unknown>
Sat, 27 Oct 2007 15:45:51 +0000
(15:45 +0000)
compiler/utils/IOEnv.hs
patch
|
blob
|
history
diff --git
a/compiler/utils/IOEnv.hs
b/compiler/utils/IOEnv.hs
index
fc513a0
..
a87413b
100644
(file)
--- 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_,
-- Standard combinators, specialised
returnM, thenM, thenM_, failM, failWithM,
mappM, mappM_, mapSndM, sequenceM, sequenceM_,
- foldlM, foldrM,
+ foldlM, foldrM, anyM,
mapAndUnzipM, mapAndUnzip3M,
checkM, ifM, zipWithM, zipWithM_,
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
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) }
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
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 []
zipWithM :: (a -> b -> IOEnv env c) -> [a] -> [b] -> IOEnv env [c]
zipWithM f [] bs = return []
zipWithM f as [] = return []