From 63093c32f33ad1fcfef10d2ef6ef010c2b5471e9 Mon Sep 17 00:00:00 2001 From: hallgren Date: Thu, 8 Nov 2012 15:53:46 +0000 Subject: [PATCH] Eliminate warnings about deprecated use of catch and try This is also needed for compatibility with GHC 7.6. --- gf.cabal | 5 +++-- src/compiler/GF/Compile/GetGrammar.hs | 3 +++ src/compiler/GF/Compile/ReadFiles.hs | 2 ++ src/compiler/GF/Infra/SIO.hs | 2 +- src/compiler/GF/Infra/UseIO.hs | 5 ++++- src/compiler/GF/System/Catch.hs | 14 ++++++++++++++ src/compiler/GFServer.hs | 3 ++- 7 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 src/compiler/GF/System/Catch.hs diff --git a/gf.cabal b/gf.cabal index 0af269d29..82ec7bdfe 100644 --- a/gf.cabal +++ b/gf.cabal @@ -95,7 +95,7 @@ library Data.Binary.IEEE754 executable gf - build-depends: base >= 4.2, + build-depends: base >= 4.2 && <5, array, containers, bytestring, @@ -146,8 +146,9 @@ executable gf GF.Infra.Option GF.Infra.UseIO GF.Infra.CheckM - GF.System.Signal + GF.System.Catch GF.System.Console + GF.System.Signal GF.Command.Commands GF.Command.Interpreter GF.Command.Abstract diff --git a/src/compiler/GF/Compile/GetGrammar.hs b/src/compiler/GF/Compile/GetGrammar.hs index cc4ca841c..b8832ba64 100644 --- a/src/compiler/GF/Compile/GetGrammar.hs +++ b/src/compiler/GF/Compile/GetGrammar.hs @@ -14,8 +14,11 @@ module GF.Compile.GetGrammar (getSourceModule) where +import Prelude hiding (catch) + import GF.Data.Operations +import GF.System.Catch import GF.Infra.UseIO import GF.Infra.Option(Options,optPreprocessors,addOptions,flag) import GF.Grammar.Lexer diff --git a/src/compiler/GF/Compile/ReadFiles.hs b/src/compiler/GF/Compile/ReadFiles.hs index 276aa2975..9b23f67dc 100644 --- a/src/compiler/GF/Compile/ReadFiles.hs +++ b/src/compiler/GF/Compile/ReadFiles.hs @@ -23,6 +23,8 @@ module GF.Compile.ReadFiles gfoFile,gfFile,isGFO,gf2gfo, getOptionsFromFile) where +import Prelude hiding (catch) +import GF.System.Catch import GF.Infra.UseIO import GF.Infra.Option import GF.Infra.Ident diff --git a/src/compiler/GF/Infra/SIO.hs b/src/compiler/GF/Infra/SIO.hs index c8355b293..1011b8df4 100644 --- a/src/compiler/GF/Infra/SIO.hs +++ b/src/compiler/GF/Infra/SIO.hs @@ -21,7 +21,7 @@ module GF.Infra.SIO( import Prelude hiding (putStrLn,print) import Control.Monad(liftM) import System.IO(Handle,hPutStrLn,hFlush,stdout) -import System.IO.Error(try) +import GF.System.Catch(try) import System.Cmd(system) import System.Environment(getEnv) import Control.Concurrent.Chan(newChan,writeChan,getChanContents) diff --git a/src/compiler/GF/Infra/UseIO.hs b/src/compiler/GF/Infra/UseIO.hs index b559f0e92..dec2269fd 100644 --- a/src/compiler/GF/Infra/UseIO.hs +++ b/src/compiler/GF/Infra/UseIO.hs @@ -15,14 +15,17 @@ module GF.Infra.UseIO where +import Prelude hiding (catch) + import GF.Data.Operations import GF.Infra.Option +import GF.System.Catch import Paths_gf(getDataDir) import System.Directory import System.FilePath import System.IO -import System.IO.Error +import System.IO.Error(isUserError,ioeGetErrorString) import System.Environment import System.Exit import System.CPUTime diff --git a/src/compiler/GF/System/Catch.hs b/src/compiler/GF/System/Catch.hs new file mode 100644 index 000000000..85d993435 --- /dev/null +++ b/src/compiler/GF/System/Catch.hs @@ -0,0 +1,14 @@ +-- | Isolate backwards incompatible library changes to 'catch' and 'try' +{-# LANGUAGE CPP #-} +module GF.System.Catch where +import qualified System.IO.Error as S + +#include "cabal_macros.h" + +#if MIN_VERSION_base(4,4,0) +catch = S.catchIOError +try = S.tryIOError +#else +catch = S.catch +try = S.try +#endif diff --git a/src/compiler/GFServer.hs b/src/compiler/GFServer.hs index fc0dcf347..ac14804c0 100644 --- a/src/compiler/GFServer.hs +++ b/src/compiler/GFServer.hs @@ -8,7 +8,8 @@ import Control.Monad.State(StateT(..),get,gets,put) import Control.Monad.Error(ErrorT(..),Error(..)) import System.Random(randomRIO) import System.IO(stderr,hPutStrLn) -import System.IO.Error(try,isAlreadyExistsError) +import GF.System.Catch(try) +import System.IO.Error(isAlreadyExistsError) import System.Directory(doesDirectoryExist,doesFileExist,createDirectory, setCurrentDirectory,getCurrentDirectory, getDirectoryContents,removeFile,removeDirectory)