Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update for ghc-7.6.1 not exporting catch from Prelude anymore

  • Loading branch information...
commit 650424444b02ddeec529d22c30808bdaf8a255fc 1 parent 7c7ba69
@elliottt elliottt authored
View
3  cabal-dev.cabal
@@ -105,6 +105,9 @@ Executable cabal-dev
Build-depends:
containers == 0.1.0.2
+ if impl(ghc >= 7.6.1)
+ CPP-Options: -DNO_PRELUDE_CATCH
+
Build-depends:
bytestring >= 0.9 && < 0.11,
directory >= 1.0 && < 1.3,
View
4 src/Distribution/Dev/AddSource.hs
@@ -16,6 +16,10 @@ where
#define MIN_VERSION_Cabal(a,b,c) 1
#endif
+#ifdef NO_PRELUDE_CATCH
+import Control.Exception ( catch )
+#endif
+
import Control.Applicative ( (<$>), (<*>) )
import Control.Arrow ( right )
import Control.Exception ( bracket )
View
20 src/Distribution/Dev/RewriteCabalConfig.hs
@@ -9,6 +9,8 @@ This module is written so that it will work out-of-the-box with GHC >=
6.8 && < 6.13 with no other packages installed.
-}
+{-# LANGUAGE CPP #-}
+
module Distribution.Dev.RewriteCabalConfig
( rewriteCabalConfig
, Rewrite(..)
@@ -18,6 +20,10 @@ module Distribution.Dev.RewriteCabalConfig
)
where
+#ifdef NO_PRELUDE_CATCH
+import Control.Exception ( catch, IOException )
+#endif
+
import Control.Applicative ( Applicative, pure, (<$>) )
import Data.Maybe ( fromMaybe )
import Data.Traversable ( traverse, Traversable )
@@ -38,8 +44,14 @@ readConfig s = case readFields s of
-- XXX: we should avoid this lazy IO that leaks a file handle.
readConfigF :: FilePath -> IO (Either String [Field])
-readConfigF fn =
- (readConfig <$> readUTF8File fn) `catch` \e -> return $ Left $ show e
+readConfigF fn = (readConfig <$> readUTF8File fn) `catch` handler
+ where
+#ifdef NO_PRELUDE_CATCH
+ handler :: IOException -> IO (Either String [Field])
+ handler = return . Left . show
+#else
+ handler = return . Left . show
+#endif
readConfigF_ :: FilePath -> IO [Field]
readConfigF_ fn = either error id <$> readConfigF fn
@@ -72,8 +84,8 @@ rewriteField expand field =
F l name val -> F l name <$> rewriteLeaf name val
Section l name key fs -> Section l name key <$>
rewriteSection name fs
- _ -> error $ "Only top-level fields and sections \
- \supported. Not: " ++ show field
+ _ -> error $ "Only top-level fields and sections "
+ ++ "supported. Not: " ++ show field
where
rewriteLeaf name val
| name `elem` eLeaves expand = eExpand expand val
View
4 src/Distribution/Dev/Sandbox.hs
@@ -25,6 +25,10 @@ import System.Directory ( createDirectoryIfMissing
, doesFileExist, copyFile )
import System.FilePath ( (</>) )
+#ifdef NO_PRELUDE_CATCH
+import Control.Exception ( catch )
+#endif
+
#ifdef mingw32_HOST_OS
import System.IO ( hPutStrLn, stderr )
import System.Win32.Types ( getLastError )
Please sign in to comment.
Something went wrong with that request. Please try again.