summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNickPartridge <>2019-01-11 05:06:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-01-11 05:06:00 (GMT)
commit37e1fedbf81c2f06c1c5a56e89887c2e2fc8e753 (patch)
tree8c8877d60dd1471b4d71ec364a7b32a670da0670
parent02f87141db78d36c88f24d5bcbea086136be3160 (diff)
version 0.2.6HEAD0.2.6master
-rw-r--r--Distribution/PackageDescription/TH.hs22
-rw-r--r--cabal-file-th.cabal2
2 files changed, 18 insertions, 6 deletions
diff --git a/Distribution/PackageDescription/TH.hs b/Distribution/PackageDescription/TH.hs
index 2cd0756..06f619e 100644
--- a/Distribution/PackageDescription/TH.hs
+++ b/Distribution/PackageDescription/TH.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
@@ -21,17 +22,28 @@ import Distribution.Version
import Distribution.Text
import Distribution.Compat.ReadP
-import Distribution.Verbosity (silent)
+import Distribution.Verbosity (Verbosity, silent)
import Text.PrettyPrint
-import Distribution.PackageDescription.Parse (readPackageDescription)
import System.Directory (getCurrentDirectory, getDirectoryContents)
import Data.List (isSuffixOf)
import Language.Haskell.TH (Q, Exp, stringE, runIO)
+-- readPackageDescription was deprecated by readGenericPackageDescription
+-- which was introduced in Cabal-2.0.0.2.
+-- readPackageDescription was removed in Cabal-2.2.0.0
+#if MIN_VERSION_Cabal(2,2,0)
+import Distribution.PackageDescription.Parsec (readGenericPackageDescription)
+readPkgDesc = readGenericPackageDescription
+#else
+import Distribution.PackageDescription.Parse (readPackageDescription)
+readPkgDesc = readPackageDescription
+#endif
+readPkgDesc :: Verbosity -> FilePath -> IO GenericPackageDescription
+
newtype DocString = DocString String
instance Text DocString where
- parse = DocString <$> (readS_to_P read)
+ parse = DocString `fmap` (readS_to_P read)
disp (DocString s) = text s
-- | Provides a Text instance for String, allowing text fields to be used
@@ -49,7 +61,7 @@ packageVariable = renderField currentPackageDescription
-- | Renders the package variable specified by the function, from a cabal file
-- and the given path.
packageVariableFrom :: Text a => FilePath -> (PackageDescription -> a) -> Q Exp
-packageVariableFrom s = renderField $ fmap packageDescription (readPackageDescription silent s)
+packageVariableFrom s = renderField $ fmap packageDescription (readPkgDesc silent s)
------
renderField :: Text b => IO a -> (a -> b) -> Q Exp
@@ -63,7 +75,7 @@ currentPackageDescription = fmap packageDescription $ do
dir <- getCurrentDirectory
cs <- cabalFiles dir
case cs of
- (c:_) -> readPackageDescription silent c
+ (c:_) -> readPkgDesc silent c
[] -> error $ "Couldn't find a cabal file in the current working directory (" ++ dir ++ ")"
cabalFiles :: FilePath -> IO [FilePath]
diff --git a/cabal-file-th.cabal b/cabal-file-th.cabal
index 17639f8..2523cb2 100644
--- a/cabal-file-th.cabal
+++ b/cabal-file-th.cabal
@@ -1,5 +1,5 @@
Name: cabal-file-th
-Version: 0.2.4
+Version: 0.2.6
Synopsis: Template Haskell expressions for reading fields from a project's cabal file.
Description: Template Haskell expressions for reading fields from a project's cabal file.
Homepage: http://github.com/nkpart/cabal-file-th