-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | The GHC compiler's view of the GHC package database format
--   
--   This library is shared between GHC and ghc-pkg and is used by GHC to
--   read package databases.
--   
--   It only deals with the subset of the package database that the
--   compiler cares about: modules paths etc and not package metadata like
--   description, authors etc. It is thus not a library interface to
--   ghc-pkg and is *not* suitable for modifying GHC package databases.
--   
--   The package database format and this library are constructed in such a
--   way that while ghc-pkg depends on Cabal, the GHC library and program
--   do not have to depend on Cabal.
@package bin-package-db
@version 0.0.0.0


-- | This module provides the view of GHC's database of registered packages
--   that is shared between GHC the compiler/library, and the ghc-pkg
--   program. It defines the database format that is shared between GHC and
--   ghc-pkg.
--   
--   The database format, and this library are constructed so that GHC does
--   not have to depend on the Cabal library. The ghc-pkg program acts as
--   the gateway between the external package format (which is defined by
--   Cabal) and the internal package format which is specialised just for
--   GHC.
--   
--   GHC the compiler only needs some of the information which is kept
--   about registerd packages, such as module names, various paths etc. On
--   the other hand ghc-pkg has to keep all the information from Cabal
--   packages and be able to regurgitate it for users and other tools.
--   
--   The first trick is that we duplicate some of the information in the
--   package database. We essentially keep two versions of the datbase in
--   one file, one version used only by ghc-pkg which keeps the full
--   information (using the serialised form of the
--   <a>InstalledPackageInfo</a> type defined by the Cabal library); and a
--   second version written by ghc-pkg and read by GHC which has just the
--   subset of information that GHC needs.
--   
--   The second trick is that this module only defines in detail the format
--   of the second version -- the bit GHC uses -- and the part managed by
--   ghc-pkg is kept in the file but here we treat it as an opaque blob of
--   data. That way this library avoids depending on Cabal.
module GHC.PackageDb

-- | This is a subset of Cabal's <a>InstalledPackageInfo</a>, with just the
--   bits that GHC is interested in.
data InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename
InstalledPackageInfo :: instpkgid -> srcpkgid -> srcpkgname -> Version -> pkgkey -> [instpkgid] -> [FilePath] -> [String] -> [String] -> [String] -> [FilePath] -> [String] -> [FilePath] -> [String] -> [String] -> [String] -> [FilePath] -> [FilePath] -> [FilePath] -> [ExposedModule instpkgid modulename] -> [modulename] -> [(modulename, OriginalModule instpkgid modulename)] -> Bool -> Bool -> InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename
[installedPackageId] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> instpkgid
[sourcePackageId] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> srcpkgid
[packageName] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> srcpkgname
[packageVersion] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> Version
[packageKey] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> pkgkey
[depends] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [instpkgid]
[importDirs] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [FilePath]
[hsLibraries] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [String]
[extraLibraries] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [String]
[extraGHCiLibraries] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [String]
[libraryDirs] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [FilePath]
[frameworks] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [String]
[frameworkDirs] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [FilePath]
[ldOptions] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [String]
[ccOptions] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [String]
[includes] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [String]
[includeDirs] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [FilePath]
[haddockInterfaces] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [FilePath]
[haddockHTMLs] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [FilePath]
[exposedModules] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [ExposedModule instpkgid modulename]
[hiddenModules] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [modulename]
[instantiatedWith] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> [(modulename, OriginalModule instpkgid modulename)]
[exposed] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> Bool
[trusted] :: InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename -> Bool

-- | Represents a module name which is exported by a package, stored in the
--   <a>exposedModules</a> field. A module export may be a reexport (in
--   which case <a>exposedReexport</a> is filled in with the original
--   source of the module), and may be a signature (in which case
--   'exposedSignature is filled in with what the signature was compiled
--   against). Thus:
--   
--   <ul>
--   <li><tt>ExposedModule n Nothing Nothing</tt> represents an exposed
--   module <tt>n</tt> which was defined in this package.</li>
--   <li><tt>ExposedModule n (Just o) Nothing</tt> represents a reexported
--   module <tt>n</tt> which was originally defined in <tt>o</tt>.</li>
--   <li><tt>ExposedModule n Nothing (Just s)</tt> represents an exposed
--   signature <tt>n</tt> which was compiled against the implementation
--   <tt>s</tt>.</li>
--   <li><tt>ExposedModule n (Just o) (Just s)</tt> represents a reexported
--   signature which was originally defined in <tt>o</tt> and was compiled
--   against the implementation <tt>s</tt>.</li>
--   </ul>
--   
--   We use two <a>Maybe</a> data types instead of an ADT with four
--   branches or four fields because this representation allows us to treat
--   reexports/signatures uniformly.
data ExposedModule instpkgid modulename
ExposedModule :: modulename -> Maybe (OriginalModule instpkgid modulename) -> Maybe (OriginalModule instpkgid modulename) -> ExposedModule instpkgid modulename
[exposedName] :: ExposedModule instpkgid modulename -> modulename
[exposedReexport] :: ExposedModule instpkgid modulename -> Maybe (OriginalModule instpkgid modulename)
[exposedSignature] :: ExposedModule instpkgid modulename -> Maybe (OriginalModule instpkgid modulename)

-- | An original module is a fully-qualified module name (installed package
--   ID plus module name) representing where a module was *originally*
--   defined (i.e., the <a>exposedReexport</a> field of the original
--   ExposedModule entry should be <a>Nothing</a>). Invariant: an
--   OriginalModule never points to a reexport.
data OriginalModule instpkgid modulename
OriginalModule :: instpkgid -> modulename -> OriginalModule instpkgid modulename
[originalPackageId] :: OriginalModule instpkgid modulename -> instpkgid
[originalModuleName] :: OriginalModule instpkgid modulename -> modulename
class BinaryStringRep a
fromStringRep :: BinaryStringRep a => ByteString -> a
toStringRep :: BinaryStringRep a => a -> ByteString
emptyInstalledPackageInfo :: (BinaryStringRep a, BinaryStringRep b, BinaryStringRep c, BinaryStringRep d) => InstalledPackageInfo a b c d e

-- | Read the part of the package DB that GHC is interested in.
readPackageDbForGhc :: (BinaryStringRep a, BinaryStringRep b, BinaryStringRep c, BinaryStringRep d, BinaryStringRep e) => FilePath -> IO [InstalledPackageInfo a b c d e]

-- | Read the part of the package DB that ghc-pkg is interested in
--   
--   Note that the Binary instance for ghc-pkg's representation of packages
--   is not defined in this package. This is because ghc-pkg uses Cabal
--   types (and Binary instances for these) which this package does not
--   depend on.
readPackageDbForGhcPkg :: Binary pkgs => FilePath -> IO pkgs

-- | Write the whole of the package DB, both parts.
writePackageDb :: (Binary pkgs, BinaryStringRep a, BinaryStringRep b, BinaryStringRep c, BinaryStringRep d, BinaryStringRep e) => FilePath -> [InstalledPackageInfo a b c d e] -> pkgs -> IO ()
instance (GHC.Show.Show instpkgid, GHC.Show.Show srcpkgid, GHC.Show.Show srcpkgname, GHC.Show.Show pkgkey, GHC.Show.Show modulename) => GHC.Show.Show (GHC.PackageDb.InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename)
instance (GHC.Classes.Eq instpkgid, GHC.Classes.Eq srcpkgid, GHC.Classes.Eq srcpkgname, GHC.Classes.Eq pkgkey, GHC.Classes.Eq modulename) => GHC.Classes.Eq (GHC.PackageDb.InstalledPackageInfo instpkgid srcpkgid srcpkgname pkgkey modulename)
instance (GHC.Show.Show instpkgid, GHC.Show.Show modulename) => GHC.Show.Show (GHC.PackageDb.ExposedModule instpkgid modulename)
instance (GHC.Classes.Eq instpkgid, GHC.Classes.Eq modulename) => GHC.Classes.Eq (GHC.PackageDb.ExposedModule instpkgid modulename)
instance (GHC.Show.Show instpkgid, GHC.Show.Show modulename) => GHC.Show.Show (GHC.PackageDb.OriginalModule instpkgid modulename)
instance (GHC.Classes.Eq instpkgid, GHC.Classes.Eq modulename) => GHC.Classes.Eq (GHC.PackageDb.OriginalModule instpkgid modulename)
instance (GHC.PackageDb.BinaryStringRep a, GHC.PackageDb.BinaryStringRep b, GHC.PackageDb.BinaryStringRep c, GHC.PackageDb.BinaryStringRep d, GHC.PackageDb.BinaryStringRep e) => Data.Binary.Class.Binary (GHC.PackageDb.InstalledPackageInfo a b c d e)
instance Data.Binary.Class.Binary Data.Version.Version
instance (GHC.PackageDb.BinaryStringRep a, GHC.PackageDb.BinaryStringRep b) => Data.Binary.Class.Binary (GHC.PackageDb.OriginalModule a b)
instance (GHC.PackageDb.BinaryStringRep a, GHC.PackageDb.BinaryStringRep b) => Data.Binary.Class.Binary (GHC.PackageDb.ExposedModule a b)
