Skip to content

Commit

Permalink
Paths_ module: don't require base >= 4.
Browse files Browse the repository at this point in the history
Fixes #994.
  • Loading branch information
23Skidoo committed Apr 23, 2015
1 parent 8a09d3e commit 41b3c7b
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Cabal/Distribution/Simple/Build/PathsModule.hs
Expand Up @@ -50,7 +50,10 @@ import Data.Maybe

generate :: PackageDescription -> LocalBuildInfo -> String
generate pkg_descr lbi =
let pragmas = ffi_pragmas ++ warning_pragmas
let pragmas = cpp_pragma ++ ffi_pragmas ++ warning_pragmas

cpp_pragma | supports_cpp = "{-# LANGUAGE CPP #-}"
| otherwise = ""

ffi_pragmas
| absolute = ""
Expand Down Expand Up @@ -89,7 +92,21 @@ generate pkg_descr lbi =
reloc_imports ++
"import Prelude\n"++
"\n"++
"catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a\n"++
(if supports_cpp
then
("#if defined(VERSION_base)\n"++
"\n"++
"#if MIN_VERSION_base(4,0,0)\n"++
"catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a\n"++
"#else\n"++
"catchIO :: IO a -> (Exception.Exception -> IO a) -> IO a\n"++
"#endif\n"++
"\n"++
"#else\n"++
"catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a\n"++
"#endif\n")
else
"catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a\n")++
"catchIO = Exception.catch\n" ++
"\n"++
"version :: Version"++
Expand Down Expand Up @@ -218,6 +235,8 @@ generate pkg_descr lbi =

path_sep = show [pathSeparator]

supports_cpp = compilerFlavor (compiler lbi) == GHC

supports_language_pragma =
(compilerFlavor (compiler lbi) == GHC &&
(compilerVersion (compiler lbi)
Expand Down

0 comments on commit 41b3c7b

Please sign in to comment.