cabal-file-th 0.2.6 → 0.2.7
raw patch · 2 files changed
+32/−3 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Distribution.PackageDescription.TH: data Version
Files
Distribution/PackageDescription/TH.hs view
@@ -13,15 +13,25 @@ -- | The data structures for the cabal file are re-exported here for ease of use. PackageDescription(..), PackageIdentifier(..),+#if MIN_VERSION_Cabal(2,0,0)+ module Distribution.Version+#else Version(..)+#endif ) where import Distribution.PackageDescription import Distribution.Package import Distribution.Version +-- Distribution.Text is deprecated and Distribution.Compat.ReadP+-- was removed in Cabal-3.0.0.0+#if MIN_VERSION_Cabal(3,0,0)+import Distribution.Pretty+#else import Distribution.Text import Distribution.Compat.ReadP+#endif import Distribution.Verbosity (Verbosity, silent) import Text.PrettyPrint import System.Directory (getCurrentDirectory, getDirectoryContents)@@ -42,11 +52,17 @@ newtype DocString = DocString String +-- Text class was removed in Cabal-3.0.0.0+#if MIN_VERSION_Cabal(3,0,0)+instance Pretty DocString where+ pretty (DocString s) = text s+#else instance Text DocString where parse = DocString `fmap` (readS_to_P read) disp (DocString s) = text s+#endif --- | Provides a Text instance for String, allowing text fields to be used+-- | Provides a Pretty instance for String, allowing text fields to be used -- in `packageVariable`. Use it composed with an accessor, eg. -- packageVariable (packageString . copyright) packageString :: String -> DocString@@ -55,17 +71,31 @@ -- | Renders the package variable specified by the function. -- The cabal file interrogated is the first one that is found -- in the current working directory.++#if MIN_VERSION_Cabal(3,0,0)+packageVariable :: Pretty a => (PackageDescription -> a) -> Q Exp+#else packageVariable :: Text a => (PackageDescription -> a) -> Q Exp+#endif packageVariable = renderField currentPackageDescription -- | Renders the package variable specified by the function, from a cabal file -- and the given path.+#if MIN_VERSION_Cabal(3,0,0)+packageVariableFrom :: Pretty a => FilePath -> (PackageDescription -> a) -> Q Exp+#else packageVariableFrom :: Text a => FilePath -> (PackageDescription -> a) -> Q Exp+#endif packageVariableFrom s = renderField $ fmap packageDescription (readPkgDesc silent s) ------+#if MIN_VERSION_Cabal(3,0,0)+renderField :: Pretty b => IO a -> (a -> b) -> Q Exp+renderField pd f = renderFieldS pd (prettyShow . f)+#else renderField :: Text b => IO a -> (a -> b) -> Q Exp renderField pd f = renderFieldS pd (display . f)+#endif renderFieldS :: IO a -> (a -> String) -> Q Exp renderFieldS pd f = runIO pd >>= stringE . f
cabal-file-th.cabal view
@@ -1,5 +1,5 @@ Name: cabal-file-th-Version: 0.2.6+Version: 0.2.7 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@@ -16,7 +16,6 @@ type: git location: git://github.com/nkpart/cabal-file-th.git - Library Exposed-modules: Distribution.PackageDescription.TH Build-depends: base >= 4 && < 5,