Commit cbc1a1de authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Add a parser for 'key' field of InstalledPackageInfo

Rather than reusing the one for ComponentId.
parent 7637d067
...@@ -55,6 +55,7 @@ import qualified Distribution.Compat.ReadP as Parse ...@@ -55,6 +55,7 @@ import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.Graph import Distribution.Compat.Graph
import Text.PrettyPrint as Disp import Text.PrettyPrint as Disp
import qualified Data.Char as Char
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
-- The InstalledPackageInfo type -- The InstalledPackageInfo type
...@@ -233,6 +234,13 @@ showInstalledPackageInfoField = showSingleNamedField fieldsInstalledPackageInfo ...@@ -233,6 +234,13 @@ showInstalledPackageInfoField = showSingleNamedField fieldsInstalledPackageInfo
showSimpleInstalledPackageInfoField :: String -> Maybe (InstalledPackageInfo -> String) showSimpleInstalledPackageInfoField :: String -> Maybe (InstalledPackageInfo -> String)
showSimpleInstalledPackageInfoField = showSimpleSingleNamedField fieldsInstalledPackageInfo showSimpleInstalledPackageInfoField = showSimpleSingleNamedField fieldsInstalledPackageInfo
dispCompatPackageKey :: String -> Doc
dispCompatPackageKey = text
parseCompatPackageKey :: Parse.ReadP r String
parseCompatPackageKey = Parse.munch1 uid_char
where uid_char c = Char.isAlphaNum c || c `elem` "-_.=[],:<>+"
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
-- Description of the fields, for parsing/printing -- Description of the fields, for parsing/printing
...@@ -250,9 +258,8 @@ basicFieldDescrs = ...@@ -250,9 +258,8 @@ basicFieldDescrs =
, simpleField "id" , simpleField "id"
disp parse disp parse
installedUnitId (\pk pkg -> pkg{installedUnitId=pk}) installedUnitId (\pk pkg -> pkg{installedUnitId=pk})
-- NB: parse these as component IDs
, simpleField "key" , simpleField "key"
(disp . mkComponentId) (fmap unComponentId parse) dispCompatPackageKey parseCompatPackageKey
compatPackageKey (\pk pkg -> pkg{compatPackageKey=pk}) compatPackageKey (\pk pkg -> pkg{compatPackageKey=pk})
, simpleField "license" , simpleField "license"
disp parseLicenseQ disp parseLicenseQ
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment