diff options
author | Ian Lynagh <igloo@earth.li> | 2010-12-18 21:33:50 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2010-12-18 21:33:50 +0000 |
commit | b00e3a6c0a82a8af3238d677f798d812cd7fd49f (patch) | |
tree | 221590400c93958028a5538f2767b6c2a2ab158c /compiler | |
parent | 50769d7532f90b0ec1f1759a56d478cf2926a0ff (diff) | |
download | haskell-b00e3a6c0a82a8af3238d677f798d812cd7fd49f.tar.gz |
Replace uses of the old catch function with the new one
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/coreSyn/MkExternalCore.lhs | 7 | ||||
-rw-r--r-- | compiler/main/SysTools.lhs | 10 | ||||
-rw-r--r-- | compiler/parser/ParserCoreUtils.hs | 3 | ||||
-rw-r--r-- | compiler/utils/Util.lhs | 9 |
4 files changed, 16 insertions, 13 deletions
diff --git a/compiler/coreSyn/MkExternalCore.lhs b/compiler/coreSyn/MkExternalCore.lhs index 9b9ca5e7c9..cb784e8ab4 100644 --- a/compiler/coreSyn/MkExternalCore.lhs +++ b/compiler/coreSyn/MkExternalCore.lhs @@ -27,6 +27,7 @@ import Encoding import ForeignCall import DynFlags import FastString +import Exception import Data.Char import System.IO @@ -35,10 +36,10 @@ emitExternalCore :: DynFlags -> CgGuts -> IO () emitExternalCore dflags cg_guts | dopt Opt_EmitExternalCore dflags = (do handle <- openFile corename WriteMode - hPutStrLn handle (show (mkExternalCore cg_guts)) + hPutStrLn handle (show (mkExternalCore cg_guts)) hClose handle) - `catch` (\_ -> pprPanic "Failed to open or write external core output file" - (text corename)) + `catchIO` (\_ -> pprPanic "Failed to open or write external core output file" + (text corename)) where corename = extCoreName dflags emitExternalCore _ _ | otherwise diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs index fb07875873..d33fd6c8c6 100644 --- a/compiler/main/SysTools.lhs +++ b/compiler/main/SysTools.lhs @@ -45,8 +45,8 @@ import ErrUtils import Panic import Util import DynFlags - import Exception + import Data.IORef import Control.Monad import System.Exit @@ -528,7 +528,7 @@ getTempDir dflags@(DynFlags{tmpDir=tmp_dir}) writeIORef ref mapping' debugTraceMsg dflags 2 (ptext (sLit "Created temporary directory:") <+> text dirname) return dirname - `IO.catch` \e -> + `catchIO` \e -> if isAlreadyExistsError e then mkTempDir (x+1) else ioError e @@ -567,7 +567,7 @@ removeTmpFiles dflags fs (non_deletees, deletees) = partition isHaskellUserSrcFilename fs removeWith :: DynFlags -> (FilePath -> IO ()) -> FilePath -> IO () -removeWith dflags remover f = remover f `IO.catch` +removeWith dflags remover f = remover f `catchIO` (\e -> let msg = if isDoesNotExistError e then ptext (sLit "Warning: deleting non-existent") <+> text f @@ -604,7 +604,7 @@ runSomethingFiltered dflags filter_fn phase_name pgm args mb_env = do #endif traceCmd dflags phase_name cmdLine $ do (exit_code, doesn'tExist) <- - IO.catch (do + catchIO (do rc <- builderMainLoop dflags filter_fn pgm real_args mb_env case rc of ExitSuccess{} -> return (rc, False) @@ -756,7 +756,7 @@ traceCmd dflags phase_name cmd_line action ; unless (dopt Opt_DryRun dflags) $ do { -- And run it! - ; action `IO.catch` handle_exn verb + ; action `catchIO` handle_exn verb }} where handle_exn _verb exn = do { debugTraceMsg dflags 2 (char '\n') diff --git a/compiler/parser/ParserCoreUtils.hs b/compiler/parser/ParserCoreUtils.hs index 2c88aa79e3..8f67d96239 100644 --- a/compiler/parser/ParserCoreUtils.hs +++ b/compiler/parser/ParserCoreUtils.hs @@ -1,5 +1,6 @@ module ParserCoreUtils where +import Exception import System.IO data ParseResult a = OkP a | FailP String @@ -19,7 +20,7 @@ failP s s' _ = FailP (s ++ ":" ++ s') getCoreModuleName :: FilePath -> IO String getCoreModuleName fpath = - catch (do + catchIO (do h <- openFile fpath ReadMode ls <- hGetContents h let mo = findMod (words ls) diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index 55a1a4f566..01a293dcbd 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -86,6 +86,7 @@ module Util ( #include "HsVersions.h" +import Exception import Panic import Data.Data @@ -99,7 +100,7 @@ import FastTypes #endif import Control.Monad ( unless ) -import System.IO.Error as IO ( catch, isDoesNotExistError ) +import System.IO.Error as IO ( isDoesNotExistError ) import System.Directory ( doesDirectoryExist, createDirectory, getModificationTime ) import System.FilePath @@ -939,9 +940,9 @@ doesDirNameExist fpath = case takeDirectory fpath of modificationTimeIfExists :: FilePath -> IO (Maybe ClockTime) modificationTimeIfExists f = do (do t <- getModificationTime f; return (Just t)) - `IO.catch` \e -> if isDoesNotExistError e - then return Nothing - else ioError e + `catchIO` \e -> if isDoesNotExistError e + then return Nothing + else ioError e -- split a string at the last character where 'pred' is True, -- returning a pair of strings. The first component holds the string |