Skip to content

Commit 7759eb7

Browse files
committed
Add readGenericPackageDescription to ReadP parser
1 parent cdc2f91 commit 7759eb7

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

Cabal/Distribution/PackageDescription/Parse.hs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
module Distribution.PackageDescription.Parse (
2121
-- * Package descriptions
22+
readGenericPackageDescription,
23+
parseGenericPackageDescription,
24+
25+
-- ** Deprecated names
2226
readPackageDescription,
2327
parsePackageDescription,
2428

@@ -592,10 +596,14 @@ readHookedBuildInfo :: Verbosity -> FilePath -> IO HookedBuildInfo
592596
readHookedBuildInfo =
593597
readAndParseFile withFileContents parseHookedBuildInfo
594598

595-
-- |Parse the given package file.
596599
readPackageDescription :: Verbosity -> FilePath -> IO GenericPackageDescription
597-
readPackageDescription =
598-
readAndParseFile withUTF8FileContents parsePackageDescription
600+
readPackageDescription = readGenericPackageDescription
601+
{-# DEPRECATED readPackageDescription "Use readGenericPackageDescription, old name is missleading." #-}
602+
603+
-- | Parse the given package file.
604+
readGenericPackageDescription :: Verbosity -> FilePath -> IO GenericPackageDescription
605+
readGenericPackageDescription =
606+
readAndParseFile withUTF8FileContents parseGenericPackageDescription
599607

600608
stanzas :: [Field] -> [[Field]]
601609
stanzas [] = []
@@ -713,12 +721,16 @@ skipField = modify tail
713721
--FIXME: this should take a ByteString, not a String. We have to be able to
714722
-- decode UTF8 and handle the BOM.
715723

724+
parsePackageDescription :: String -> ParseResult GenericPackageDescription
725+
parsePackageDescription = parseGenericPackageDescription
726+
{-# DEPRECATED parsePackageDescription "Use parseGenericPackageDescription, old name is missleading" #-}
727+
716728
-- | Parses the given file into a 'GenericPackageDescription'.
717729
--
718730
-- In Cabal 1.2 the syntax for package descriptions was changed to a format
719731
-- with sections and possibly indented property descriptions.
720-
parsePackageDescription :: String -> ParseResult GenericPackageDescription
721-
parsePackageDescription file = do
732+
parseGenericPackageDescription :: String -> ParseResult GenericPackageDescription
733+
parseGenericPackageDescription file = do
722734

723735
-- This function is quite complex because it needs to be able to parse
724736
-- both pre-Cabal-1.2 and post-Cabal-1.2 files. Additionally, it contains

Cabal/Distribution/Simple.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,8 @@ confPkgDescr hooks verbosity mb_path = do
237237
Just path -> return path
238238
#ifdef CABAL_PARSEC
239239
info verbosity "Using Parsec parser"
240-
descr <- readGenericPackageDescription verbosity pdfile
241-
#else
242-
descr <- readPackageDescription verbosity pdfile
243240
#endif
241+
descr <- readGenericPackageDescription verbosity pdfile
244242
return (Just pdfile, descr)
245243

246244
buildAction :: UserHooks -> BuildFlags -> Args -> IO ()

0 commit comments

Comments
 (0)