2 -- (c) The University of Glasgow, 2004
8 mkPackageId, stringToPackageId, packageIdString, packageConfigId,
9 packageIdFS, fsToPackageId,
11 -- * The PackageConfig type: information about a package
13 InstalledPackageInfo(..), showPackageId,
15 PackageIdentifier(..),
19 #include "HsVersions.h"
21 import Distribution.InstalledPackageInfo
22 import Distribution.Package
23 import Distribution.Version
26 -- -----------------------------------------------------------------------------
27 -- Our PackageConfig type is just InstalledPackageInfo from Cabal. Later we
28 -- might need to extend it with some GHC-specific stuff, but for now it's fine.
30 type PackageConfig = InstalledPackageInfo
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 newtype PackageId = PId FastString deriving( Eq, Ord ) -- includes the version
48 -- easier not to use a newtype here, because we need instances of
49 -- Binary & Outputable, and we're too early to define them
51 fsToPackageId :: FastString -> PackageId
54 packageIdFS :: PackageId -> FastString
55 packageIdFS (PId fs) = fs
57 stringToPackageId :: String -> PackageId
58 stringToPackageId = fsToPackageId . mkFastString
60 packageIdString :: PackageId -> String
61 packageIdString = unpackFS . packageIdFS
63 mkPackageId :: PackageIdentifier -> PackageId
64 mkPackageId = stringToPackageId . showPackageId
66 packageConfigId :: PackageConfig -> PackageId
67 packageConfigId = mkPackageId . package