2 -- (c) The University of Glasgow, 2004
8 mkPackageId, stringToPackageId, packageIdString, packageConfigId,
10 -- * The PackageConfig type: information about a package
12 InstalledPackageInfo(..), showPackageId,
14 PackageIdentifier(..),
18 #include "HsVersions.h"
20 import Distribution.InstalledPackageInfo
21 import Distribution.Package
22 import Distribution.Version
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
30 defaultPackageConfig = emptyInstalledPackageInfo
32 -- -----------------------------------------------------------------------------
33 -- PackageId (package names with versions)
35 -- Mostly the compiler deals in terms of PackageNames, which don't
36 -- have the version suffix. This is so that we don't need to know the
37 -- version for the -package-name flag, or know the versions of
38 -- wired-in packages like base & rts. Versions are confined to the
39 -- package sub-system.
41 -- This means that in theory you could have multiple base packages installed
42 -- (for example), and switch between them using -package/-hide-package.
44 -- A PackageId is a string of the form <pkg>-<version>.
46 type PackageId = FastString -- includes the version
47 -- easier not to use a newtype here, because we need instances of
48 -- Binary & Outputable, and we're too early to define them
50 stringToPackageId :: String -> PackageId
51 stringToPackageId = mkFastString
53 mkPackageId :: PackageIdentifier -> PackageId
54 mkPackageId = stringToPackageId . showPackageId
56 packageConfigId :: PackageConfig -> PackageId
57 packageConfigId = mkPackageId . package
59 packageIdString :: PackageId -> String
60 packageIdString = unpackFS