Ticket #7262: fix_build.patch

File fix_build.patch, 3.2 KB (added by sopvop, 7 years ago)
  • System/Directory.hs

    From 6b5c5bd838f3eaf79174052846a5308725f7a3a4 Mon Sep 17 00:00:00 2001
    From: Leonid Onokhov <sopvop@gmail.com>
    Date: Sun, 23 Sep 2012 00:22:00 +0400
    Subject: [PATCH] Fix build for base < 4.6
    
    ---
     System/Directory.hs |   15 ++++++++-------
     1 file changed, 8 insertions(+), 7 deletions(-)
    
    diff --git a/System/Directory.hs b/System/Directory.hs
    index 1e44248..7feee81 100644
    a b import System.IO 
    8686import System.IO.Error
    8787import Control.Monad           ( when, unless )
    8888import Control.Exception.Base
     89import qualified Control.Exception.Base as E
    8990
    9091#ifdef __NHC__
    9192import Directory -- hiding ( getDirectoryContents
    createDirectoryIfMissing create_parents path0 
    392393
    393394    createDir :: FilePath -> (IOException -> IO ()) -> IO ()
    394395    createDir dir notExistHandler = do
    395       r <- try $ createDirectory dir
     396      r <- E.try $ createDirectory dir
    396397      case (r :: Either IOException ()) of
    397398        Right ()                   -> return ()
    398399        Left  e
    createDirectoryIfMissing create_parents path0 
    416417                 then return ()
    417418                 else throw e
    418419#endif
    419               ) `catch` ((\_ -> return ()) :: IOException -> IO ())
     420              ) `E.catch` ((\_ -> return ()) :: IOException -> IO ())
    420421          | otherwise              -> throw e
    421422#endif  /* !__NHC__ */
    422423
    removeDirectoryRecursive startLoc = do 
    482483  removeDirectory startLoc
    483484  where
    484485    rm :: FilePath -> IO ()
    485     rm f = do temp <- try (removeFile f)
     486    rm f = do temp <- E.try (removeFile f)
    486487              case temp of
    487488                Left e  -> do isDir <- doesDirectoryExist f
    488489                              -- If f is not a directory, re-throw the error
    doesDirectoryExist name = 
    957958   (do stat <- Posix.getFileStatus name
    958959       return (Posix.isDirectory stat))
    959960#endif
    960    `catch` ((\ _ -> return False) :: IOException -> IO Bool)
     961   `E.catch` ((\ _ -> return False) :: IOException -> IO Bool)
    961962
    962963{- |The operation 'doesFileExist' returns 'True'
    963964if the argument file exists and is not a directory, and 'False' otherwise.
    doesFileExist name = 
    971972   (do stat <- Posix.getFileStatus name
    972973       return (not (Posix.isDirectory stat)))
    973974#endif
    974    `catch` ((\ _ -> return False) :: IOException -> IO Bool)
     975   `E.catch` ((\ _ -> return False) :: IOException -> IO Bool)
    975976
    976977{- |The 'getModificationTime' operation returns the
    977978clock time at which the file or directory was last modified.
    getHomeDirectory :: IO FilePath 
    10711072getHomeDirectory =
    10721073  modifyIOError ((`ioeSetLocation` "getHomeDirectory")) $ do
    10731074#if defined(mingw32_HOST_OS)
    1074     r <- try $ Win32.sHGetFolderPath nullPtr Win32.cSIDL_PROFILE nullPtr 0
     1075    r <- E.try $ Win32.sHGetFolderPath nullPtr Win32.cSIDL_PROFILE nullPtr 0
    10751076    case (r :: Either IOException String) of
    10761077      Right s -> return s
    10771078      Left  _ -> do
    1078         r1 <- try $ Win32.sHGetFolderPath nullPtr Win32.cSIDL_WINDOWS nullPtr 0
     1079        r1 <- E.try $ Win32.sHGetFolderPath nullPtr Win32.cSIDL_WINDOWS nullPtr 0
    10791080        case r1 of
    10801081          Right s -> return s
    10811082          Left  e -> ioError (e :: IOException)