module Distribution.InstalledPackageInfo (
InstalledPackageInfo_(..), InstalledPackageInfo,
ParseResult(..), PError(..), PWarning,
emptyInstalledPackageInfo,
parseInstalledPackageInfo,
showInstalledPackageInfo,
showInstalledPackageInfoField,
fieldsInstalledPackageInfo,
) where
import Distribution.ParseUtils
( FieldDescr(..), ParseResult(..), PError(..), PWarning
, simpleField, listField, parseLicenseQ
, showFields, showSingleNamedField, parseFieldsFlat
, parseFilePathQ, parseTokenQ, parseModuleNameQ, parsePackageNameQ
, showFilePath, showToken, boolField, parseOptVersion
, parseFreeText, showFreeText )
import Distribution.License ( License(..) )
import Distribution.Package
( PackageName(..), PackageIdentifier(..), PackageId, InstalledPackageId(..)
, packageName, packageVersion )
import qualified Distribution.Package as Package
( Package(..) )
import Distribution.ModuleName
( ModuleName )
import Distribution.Version
( Version(..) )
import Distribution.Text
( Text(disp, parse) )
data installedPackageId :: InstalledPackageIdInstalledPackageInfo_ m
= InstalledPackageInfo {
installedPackageId :: InstalledPackageId,
sourcePackageId :: PackageId,
license :: License,
copyright :: String,
maintainer :: String,
author :: String,
stability :: String,
homepage :: String,
pkgUrl :: String,
synopsis :: String,
description :: String,
category :: String,
exposed :: Bool,
exposedModules :: [m],
hiddenModules :: [m],
importDirs :: [FilePath],
libraryDirs :: [FilePath],
hsLibraries :: [String],
extraLibraries :: [String],
extraGHCiLibraries:: [String],
includeDirs :: [FilePath],
includes :: [String],
depends :: [InstalledPackageId],
hugsOptions :: [String],
ccOptions :: [String],
ldOptions :: [String],
frameworkDirs :: [FilePath],
frameworks :: [String],
haddockInterfaces :: [FilePath],
haddockHTMLs :: [FilePath]
}
deriving (D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow)
instance ($cpackageId) :: InstalledPackageInfo_ str -> PackageIdentifierPackage.Package (InstalledPackageInfo_ str) where
packageId = sourcePackageId :: InstalledPackageInfo_ m -> PackageIdsourcePackageId
type InstalledPackageInfo = InstalledPackageInfo_ ModuleName
emptyInstalledPackageInfo :: InstalledPackageInfo_ m
emptyInstalledPackageInfo
= InstalledPackageInfo {
installedPackageId = InstalledPackageId :: String -> InstalledPackageIdInstalledPackageId "",
sourcePackageId = PackageIdentifier :: PackageName -> Version -> PackageIdentifierPackageIdentifier (PackageName :: String -> PackageNamePackageName "") noVersion :: VersionnoVersion,
license = AllRightsReserved :: LicenseAllRightsReserved,
copyright = "",
maintainer = "",
author = "",
stability = "",
homepage = "",
pkgUrl = "",
synopsis = "",
description = "",
category = "",
exposed = False :: BoolFalse,
exposedModules = [] :: [a][],
hiddenModules = [] :: [a][],
importDirs = [] :: [a][],
libraryDirs = [] :: [a][],
hsLibraries = [] :: [a][],
extraLibraries = [] :: [a][],
extraGHCiLibraries= [] :: [a][],
includeDirs = [] :: [a][],
includes = [] :: [a][],
depends = [] :: [a][],
hugsOptions = [] :: [a][],
ccOptions = [] :: [a][],
ldOptions = [] :: [a][],
frameworkDirs = [] :: [a][],
frameworks = [] :: [a][],
haddockInterfaces = [] :: [a][],
haddockHTMLs = [] :: [a][]
}
noVersion :: Version
noVersion = Version{ versionBranch=[] :: [a][], versionTags=[] :: [a][] }
parseInstalledPackageInfo :: String -> ParseResult InstalledPackageInfo
parseInstalledPackageInfo =
parseFieldsFlat :: [FieldDescr a] -> a -> String -> ParseResult aparseFieldsFlat fieldsInstalledPackageInfo :: [FieldDescr InstalledPackageInfo]fieldsInstalledPackageInfo emptyInstalledPackageInfo :: InstalledPackageInfo_ memptyInstalledPackageInfo
showInstalledPackageInfo :: InstalledPackageInfo -> String
showInstalledPackageInfo = showFields :: [FieldDescr a] -> a -> StringshowFields fieldsInstalledPackageInfo :: [FieldDescr InstalledPackageInfo]fieldsInstalledPackageInfo
showInstalledPackageInfoField :: String -> Maybe (InstalledPackageInfo -> String)
showInstalledPackageInfoField = showSingleNamedField ::
[FieldDescr a] -> String -> Maybe (a -> String)showSingleNamedField fieldsInstalledPackageInfo :: [FieldDescr InstalledPackageInfo]fieldsInstalledPackageInfo
fieldsInstalledPackageInfo :: [FieldDescr InstalledPackageInfo]
fieldsInstalledPackageInfo = basicFieldDescrs :: [FieldDescr InstalledPackageInfo]basicFieldDescrs (++) :: [a] -> [a] -> [a]++ installedFieldDescrs :: [FieldDescr InstalledPackageInfo]installedFieldDescrs
basicFieldDescrs :: [FieldDescr InstalledPackageInfo]
basicFieldDescrs =
[ simpleField ::
String
-> (a -> Doc)
-> ReadP a a
-> (b -> a)
-> (a -> b -> b)
-> FieldDescr bsimpleField "name"
disp :: Text a => a -> Docdisp parsePackageNameQ :: ReadP r PackageNameparsePackageNameQ
packageName :: Package pkg => pkg -> PackageNamepackageName (\name pkg -> pkg :: InstalledPackageInfopkg{sourcePackageId=(sourcePackageId :: InstalledPackageInfo_ m -> PackageIdsourcePackageId pkg :: InstalledPackageInfopkg){pkgName=name :: PackageNamename}})
, simpleField ::
String
-> (a -> Doc)
-> ReadP a a
-> (b -> a)
-> (a -> b -> b)
-> FieldDescr bsimpleField "version"
disp :: Text a => a -> Docdisp parseOptVersion :: ReadP r VersionparseOptVersion
packageVersion :: Package pkg => pkg -> VersionpackageVersion (\ver pkg -> pkg :: InstalledPackageInfopkg{sourcePackageId=(sourcePackageId :: InstalledPackageInfo_ m -> PackageIdsourcePackageId pkg :: InstalledPackageInfopkg){pkgVersion=ver :: Versionver}})
, simpleField ::
String
-> (a -> Doc)
-> ReadP a a
-> (b -> a)
-> (a -> b -> b)
-> FieldDescr bsimpleField "id"
disp :: Text a => a -> Docdisp parse :: Text a => forall r. ReadP r aparse
installedPackageId :: InstalledPackageInfo_ m -> InstalledPackageIdinstalledPackageId (\ipid pkg -> pkg :: InstalledPackageInfopkg{installedPackageId=ipid :: InstalledPackageIdipid})
, simpleField ::
String
-> (a -> Doc)
-> ReadP a a
-> (b -> a)
-> (a -> b -> b)
-> FieldDescr bsimpleField "license"
disp :: Text a => a -> Docdisp parseLicenseQ :: ReadP r LicenseparseLicenseQ
license :: InstalledPackageInfo_ m -> Licenselicense (\l pkg -> pkg :: InstalledPackageInfopkg{license=l :: Licensel})
, simpleField ::
String
-> (a -> Doc)
-> ReadP a a
-> (b -> a)
-> (a -> b -> b)
-> FieldDescr bsimpleField "copyright"
showFreeText :: String -> DocshowFreeText parseFreeText :: ReadP s StringparseFreeText
copyright :: InstalledPackageInfo_ m -> Stringcopyright (\val pkg -> pkg :: InstalledPackageInfopkg{copyright=val :: Stringval})
, simpleField ::
String
-> (a -> Doc)
-> ReadP a a
-> (b -> a)
-> (a -> b -> b)
-> FieldDescr bsimpleField "maintainer"
showFreeText :: String -> DocshowFreeText parseFreeText :: ReadP s StringparseFreeText
maintainer :: InstalledPackageInfo_ m -> Stringmaintainer (\val pkg -> pkg :: InstalledPackageInfopkg{maintainer=val :: Stringval})
, simpleField ::
String
-> (a -> Doc)
-> ReadP a a
-> (b -> a)
-> (a -> b -> b)
-> FieldDescr bsimpleField "stability"
showFreeText :: String -> DocshowFreeText parseFreeText :: ReadP s StringparseFreeText
stability :: InstalledPackageInfo_ m -> Stringstability (\val pkg -> pkg :: InstalledPackageInfopkg{stability=val :: Stringval})
, simpleField ::
String
-> (a -> Doc)
-> ReadP a a
-> (b -> a)
-> (a -> b -> b)
-> FieldDescr bsimpleField "homepage"
showFreeText :: String -> DocshowFreeText parseFreeText :: ReadP s StringparseFreeText
homepage :: InstalledPackageInfo_ m -> Stringhomepage (\val pkg -> pkg :: InstalledPackageInfopkg{homepage=val :: Stringval})
, simpleField ::
String
-> (a -> Doc)
-> ReadP a a
-> (b -> a)
-> (a -> b -> b)
-> FieldDescr bsimpleField "package-url"
showFreeText :: String -> DocshowFreeText parseFreeText :: ReadP s StringparseFreeText
pkgUrl :: InstalledPackageInfo_ m -> StringpkgUrl (\val pkg -> pkg :: InstalledPackageInfopkg{pkgUrl=val :: Stringval})
, simpleField ::
String
-> (a -> Doc)
-> ReadP a a
-> (b -> a)
-> (a -> b -> b)
-> FieldDescr bsimpleField "synopsis"
showFreeText :: String -> DocshowFreeText parseFreeText :: ReadP s StringparseFreeText
synopsis :: InstalledPackageInfo_ m -> Stringsynopsis (\val pkg -> pkg :: InstalledPackageInfopkg{synopsis=val :: Stringval})
, simpleField ::
String
-> (a -> Doc)
-> ReadP a a
-> (b -> a)
-> (a -> b -> b)
-> FieldDescr bsimpleField "description"
showFreeText :: String -> DocshowFreeText parseFreeText :: ReadP s StringparseFreeText
description :: InstalledPackageInfo_ m -> Stringdescription (\val pkg -> pkg :: InstalledPackageInfopkg{description=val :: Stringval})
, simpleField ::
String
-> (a -> Doc)
-> ReadP a a
-> (b -> a)
-> (a -> b -> b)
-> FieldDescr bsimpleField "category"
showFreeText :: String -> DocshowFreeText parseFreeText :: ReadP s StringparseFreeText
category :: InstalledPackageInfo_ m -> Stringcategory (\val pkg -> pkg :: InstalledPackageInfopkg{category=val :: Stringval})
, simpleField ::
String
-> (a -> Doc)
-> ReadP a a
-> (b -> a)
-> (a -> b -> b)
-> FieldDescr bsimpleField "author"
showFreeText :: String -> DocshowFreeText parseFreeText :: ReadP s StringparseFreeText
author :: InstalledPackageInfo_ m -> Stringauthor (\val pkg -> pkg :: InstalledPackageInfopkg{author=val :: Stringval})
]
installedFieldDescrs :: [FieldDescr InstalledPackageInfo]
installedFieldDescrs = [
boolField ::
String -> (b -> Bool) -> (Bool -> b -> b) -> FieldDescr bboolField "exposed"
exposed :: InstalledPackageInfo_ m -> Boolexposed (\val pkg -> pkg :: InstalledPackageInfopkg{exposed=val :: Stringval})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "exposed-modules"
disp :: Text a => a -> Docdisp parseModuleNameQ :: ReadP r ModuleNameparseModuleNameQ
exposedModules :: InstalledPackageInfo_ m -> [m]exposedModules (\xs pkg -> pkg :: InstalledPackageInfopkg{exposedModules=xs :: [FilePath]xs})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "hidden-modules"
disp :: Text a => a -> Docdisp parseModuleNameQ :: ReadP r ModuleNameparseModuleNameQ
hiddenModules :: InstalledPackageInfo_ m -> [m]hiddenModules (\xs pkg -> pkg :: InstalledPackageInfopkg{hiddenModules=xs :: [FilePath]xs})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "import-dirs"
showFilePath :: FilePath -> DocshowFilePath parseFilePathQ :: ReadP r FilePathparseFilePathQ
importDirs :: InstalledPackageInfo_ m -> [FilePath]importDirs (\xs pkg -> pkg :: InstalledPackageInfopkg{importDirs=xs :: [FilePath]xs})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "library-dirs"
showFilePath :: FilePath -> DocshowFilePath parseFilePathQ :: ReadP r FilePathparseFilePathQ
libraryDirs :: InstalledPackageInfo_ m -> [FilePath]libraryDirs (\xs pkg -> pkg :: InstalledPackageInfopkg{libraryDirs=xs :: [FilePath]xs})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "hs-libraries"
showFilePath :: FilePath -> DocshowFilePath parseTokenQ :: ReadP r StringparseTokenQ
hsLibraries :: InstalledPackageInfo_ m -> [String]hsLibraries (\xs pkg -> pkg :: InstalledPackageInfopkg{hsLibraries=xs :: [FilePath]xs})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "extra-libraries"
showToken :: String -> DocshowToken parseTokenQ :: ReadP r StringparseTokenQ
extraLibraries :: InstalledPackageInfo_ m -> [String]extraLibraries (\xs pkg -> pkg :: InstalledPackageInfopkg{extraLibraries=xs :: [FilePath]xs})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "extra-ghci-libraries"
showToken :: String -> DocshowToken parseTokenQ :: ReadP r StringparseTokenQ
extraGHCiLibraries :: InstalledPackageInfo_ m -> [String]extraGHCiLibraries (\xs pkg -> pkg :: InstalledPackageInfopkg{extraGHCiLibraries=xs :: [FilePath]xs})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "include-dirs"
showFilePath :: FilePath -> DocshowFilePath parseFilePathQ :: ReadP r FilePathparseFilePathQ
includeDirs :: InstalledPackageInfo_ m -> [FilePath]includeDirs (\xs pkg -> pkg :: InstalledPackageInfopkg{includeDirs=xs :: [FilePath]xs})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "includes"
showFilePath :: FilePath -> DocshowFilePath parseFilePathQ :: ReadP r FilePathparseFilePathQ
includes :: InstalledPackageInfo_ m -> [String]includes (\xs pkg -> pkg :: InstalledPackageInfopkg{includes=xs :: [FilePath]xs})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "depends"
disp :: Text a => a -> Docdisp parse :: Text a => forall r. ReadP r aparse
depends :: InstalledPackageInfo_ m -> [InstalledPackageId]depends (\xs pkg -> pkg :: InstalledPackageInfopkg{depends=xs :: [FilePath]xs})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "hugs-options"
showToken :: String -> DocshowToken parseTokenQ :: ReadP r StringparseTokenQ
hugsOptions :: InstalledPackageInfo_ m -> [String]hugsOptions (\path pkg -> pkg :: InstalledPackageInfopkg{hugsOptions=path :: [String]path})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "cc-options"
showToken :: String -> DocshowToken parseTokenQ :: ReadP r StringparseTokenQ
ccOptions :: InstalledPackageInfo_ m -> [String]ccOptions (\path pkg -> pkg :: InstalledPackageInfopkg{ccOptions=path :: [String]path})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "ld-options"
showToken :: String -> DocshowToken parseTokenQ :: ReadP r StringparseTokenQ
ldOptions :: InstalledPackageInfo_ m -> [String]ldOptions (\path pkg -> pkg :: InstalledPackageInfopkg{ldOptions=path :: [String]path})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "framework-dirs"
showFilePath :: FilePath -> DocshowFilePath parseFilePathQ :: ReadP r FilePathparseFilePathQ
frameworkDirs :: InstalledPackageInfo_ m -> [FilePath]frameworkDirs (\xs pkg -> pkg :: InstalledPackageInfopkg{frameworkDirs=xs :: [FilePath]xs})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "frameworks"
showToken :: String -> DocshowToken parseTokenQ :: ReadP r StringparseTokenQ
frameworks :: InstalledPackageInfo_ m -> [String]frameworks (\xs pkg -> pkg :: InstalledPackageInfopkg{frameworks=xs :: [FilePath]xs})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "haddock-interfaces"
showFilePath :: FilePath -> DocshowFilePath parseFilePathQ :: ReadP r FilePathparseFilePathQ
haddockInterfaces :: InstalledPackageInfo_ m -> [FilePath]haddockInterfaces (\xs pkg -> pkg :: InstalledPackageInfopkg{haddockInterfaces=xs :: [FilePath]xs})
, listField ::
String
-> (a -> Doc)
-> ReadP [a] a
-> (b -> [a])
-> ([a] -> b -> b)
-> FieldDescr blistField "haddock-html"
showFilePath :: FilePath -> DocshowFilePath parseFilePathQ :: ReadP r FilePathparseFilePathQ
haddockHTMLs :: InstalledPackageInfo_ m -> [FilePath]haddockHTMLs (\xs pkg -> pkg :: InstalledPackageInfopkg{haddockHTMLs=xs :: [FilePath]xs})
]