X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FUtil.lhs;h=39fd64b679dafb6d36b68fee8f5620dcfdab1fca;hb=b1ab4b8a607addc4d097588db5761313c996a41f;hp=a7b65e8eb979910ee588e3f329b7b21b02501a0f;hpb=308cb59e89a5be1ed6d55da39a843ca5f1828445;p=ghc-hetmet.git diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index a7b65e8..39fd64b 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -12,7 +12,7 @@ module Util ( zipLazy, stretchZipWith, mapFst, mapSnd, mapAndUnzip, mapAndUnzip3, - nOfThem, filterOut, partitionWith, + nOfThem, filterOut, partitionWith, splitEithers, lengthExceeds, lengthIs, lengthAtLeast, listLengthCmp, atLength, equalLength, compareLength, @@ -177,6 +177,13 @@ partitionWith f (x:xs) = case f x of where (bs,cs) = partitionWith f xs +splitEithers :: [Either a b] -> ([a], [b]) +splitEithers [] = ([],[]) +splitEithers (e : es) = case e of + Left x -> (x:xs, ys) + Right y -> (xs, y:ys) + where + (xs,ys) = splitEithers es \end{code} A paranoid @zip@ (and some @zipWith@ friends) that checks the lists @@ -883,13 +890,9 @@ handleDyn :: Typeable ex => (ex -> IO a) -> IO a -> IO a handleDyn = flip catchDyn handle :: (Exception -> IO a) -> IO a -> IO a -#if __GLASGOW_HASKELL__ < 501 -handle = flip Exception.catchAllIO -#else handle h f = f `Exception.catch` \e -> case e of ExitException _ -> throw e _ -> h e -#endif -- -------------------------------------------------------------- -- check existence & modification time at the same time