2 -- (c) The University of Glasgow, 2004
7 mkPackageId, packageConfigId, unpackPackageId,
9 -- * The PackageConfig type: information about a package
11 InstalledPackageInfo_(..), showPackageId,
13 PackageIdentifier(..),
17 #include "HsVersions.h"
20 import Distribution.InstalledPackageInfo
21 import Distribution.Package
22 import Distribution.Version
23 import Distribution.Compat.ReadP ( readP_to_S )
25 -- -----------------------------------------------------------------------------
26 -- Our PackageConfig type is just InstalledPackageInfo from Cabal. Later we
27 -- might need to extend it with some GHC-specific stuff, but for now it's fine.
29 type PackageConfig = InstalledPackageInfo_ ModuleName
30 defaultPackageConfig :: PackageConfig
31 defaultPackageConfig = emptyInstalledPackageInfo
33 -- -----------------------------------------------------------------------------
34 -- PackageId (package names with versions)
36 -- Mostly the compiler deals in terms of PackageNames, which don't
37 -- have the version suffix. This is so that we don't need to know the
38 -- version for the -package-name flag, or know the versions of
39 -- wired-in packages like base & rts. Versions are confined to the
40 -- package sub-system.
42 -- This means that in theory you could have multiple base packages installed
43 -- (for example), and switch between them using -package/-hide-package.
45 -- A PackageId is a string of the form <pkg>-<version>.
47 mkPackageId :: PackageIdentifier -> PackageId
48 mkPackageId = stringToPackageId . showPackageId
50 packageConfigId :: PackageConfig -> PackageId
51 packageConfigId = mkPackageId . package
53 unpackPackageId :: PackageId -> Maybe PackageIdentifier
55 = case [ pid | (pid,"") <- readP_to_S parsePackageId str ] of
58 where str = packageIdString p