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

-- | Shared functionality between GHC and its boot libraries
--   
--   This library is shared between GHC, ghc-pkg, and other boot libraries.
--   . A note about GHC.Unit.Database: 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 ghc-boot
@version 9.10.3

-- | Note [Base Dir] ~~~~~~~~~~~~~~~~~ GHC's base directory or top
--   directory containers miscellaneous settings and the package database.
--   The main compiler of course needs this directory to read those
--   settings and read and write packages. ghc-pkg uses it to find the
--   global package database too.
--   
--   In the interest of making GHC builds more relocatable, many settings
--   also will expand `${top_dir}` inside strings so GHC doesn't need to
--   know it's on installation location at build time. ghc-pkg also can
--   expand those variables and so needs the top dir location to do that
--   too.
module GHC.BaseDir

-- | Expand occurrences of the $topdir interpolation in a string.
expandTopDir :: FilePath -> String -> String

-- | 
--   expandPathVar var value str
--   
--   
--   replaces occurrences of variable $var with value in
--   str.
expandPathVar :: String -> FilePath -> String -> String

-- | Calculate the location of the base dir
getBaseDir :: IO (Maybe String)

module GHC.Data.SizedSeq
data SizedSeq a
SizedSeq :: {-# UNPACK #-} !Word -> [a] -> SizedSeq a
emptySS :: SizedSeq a
addToSS :: SizedSeq a -> a -> SizedSeq a
addListToSS :: SizedSeq a -> [a] -> SizedSeq a
ssElts :: SizedSeq a -> [a]
sizeSS :: SizedSeq a -> Word
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (GHC.Data.SizedSeq.SizedSeq a)
instance GHC.Internal.Data.Foldable.Foldable GHC.Data.SizedSeq.SizedSeq
instance GHC.Internal.Base.Functor GHC.Data.SizedSeq.SizedSeq
instance GHC.Internal.Generics.Generic (GHC.Data.SizedSeq.SizedSeq a)
instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (GHC.Data.SizedSeq.SizedSeq a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (GHC.Data.SizedSeq.SizedSeq a)
instance GHC.Internal.Data.Traversable.Traversable GHC.Data.SizedSeq.SizedSeq

-- | See GHC.LanguageExtensions for an explanation on why this is
--   needed
module GHC.ForeignSrcLang
instance Data.Binary.Class.Binary GHC.ForeignSrcLang.Type.ForeignSrcLang

-- | See GHC #10762 and #15021.
module GHC.HandleEncoding

-- | Handle GHC-specific character encoding flags, allowing us to control
--   how GHC produces output regardless of OS.
configureHandleEncoding :: IO ()

-- | This module re-exports the Extension type along with an orphan
--   Binary instance for it.
--   
--   Note that the ghc-boot package has a large set of
--   dependencies; for this reason the Extension type itself is
--   defined in the GHC.LanguageExtensions.Type module provided by
--   the ghc-boot-th package, which has no dependencies outside of
--   base. For this reason template-haskell depends upon
--   ghc-boot-th, not ghc-boot.
module GHC.LanguageExtensions
instance Data.Binary.Class.Binary GHC.LanguageExtensions.Type.Extension

module GHC.Platform.Host
hostPlatformArch :: Arch
hostPlatformOS :: OS
hostPlatformArchOS :: ArchOS

module GHC.Serialized

-- | Represents a serialized value of a particular type. Attempts can be
--   made to deserialize it at certain types
data Serialized
Serialized :: TypeRep -> [Word8] -> Serialized

-- | Put a Typeable value that we are able to actually turn into bytes into
--   a Serialized value ready for deserialization later
toSerialized :: Typeable a => (a -> [Word8]) -> a -> Serialized

-- | If the Serialized value contains something of the given type,
--   then use the specified deserializer to return Just that.
--   Otherwise return Nothing.
fromSerialized :: Typeable a => ([Word8] -> a) -> Serialized -> Maybe a

-- | Use a Data instance to implement a serialization scheme dual to
--   that of deserializeWithData
serializeWithData :: Data a => a -> [Word8]

-- | Use a Data instance to implement a deserialization scheme dual
--   to that of serializeWithData
deserializeWithData :: Data a => [Word8] -> a

module GHC.Settings.Utils
maybeRead :: Read a => String -> Maybe a
maybeReadFuzzy :: Read a => String -> Maybe a
type RawSettings = Map String String

-- | Read target Arch/OS from the settings
getTargetArchOS :: FilePath -> RawSettings -> Either String ArchOS
getRawSetting :: FilePath -> RawSettings -> String -> Either String String
getRawFilePathSetting :: FilePath -> FilePath -> RawSettings -> String -> Either String String
getRawBooleanSetting :: FilePath -> RawSettings -> String -> Either String Bool
readRawSetting :: (Show a, Read a) => FilePath -> RawSettings -> String -> Either String a

-- | Simple, non-streaming UTF-8 codecs.
--   
--   This is one of several UTF-8 implementations provided by GHC; see Note
--   [GHC's many UTF-8 implementations] in GHC.Encoding.UTF8 for an
--   overview.
module GHC.Utils.Encoding.UTF8
utf8DecodeCharAddr# :: Addr# -> Int# -> (# Char#, Int# #)
utf8DecodeCharPtr :: Ptr Word8 -> (Char, Int)
utf8DecodeCharByteArray# :: ByteArray# -> Int# -> (# Char#, Int# #)

-- | Find the start of the codepoint preceding the codepoint at the given
--   Ptr. This is undefined if there is no previous valid codepoint.
utf8PrevChar :: Ptr Word8 -> IO (Ptr Word8)

-- | Find the start of the codepoint at the given Ptr. This is
--   undefined if there is no previous valid codepoint.
utf8CharStart :: Ptr Word8 -> IO (Ptr Word8)
utf8UnconsByteString :: ByteString -> Maybe (Char, ByteString)

-- | Decode a ByteString containing a UTF-8 string.
utf8DecodeByteString :: ByteString -> [Char]
utf8DecodeShortByteString :: ShortByteString -> [Char]
utf8DecodeForeignPtr :: ForeignPtr Word8 -> Int -> Int -> [Char]
utf8DecodeByteArray# :: ByteArray# -> [Char]
utf8CountCharsShortByteString :: ShortByteString -> Int
utf8CountCharsByteArray# :: ByteArray# -> Int
utf8CompareByteArray# :: ByteArray# -> ByteArray# -> Ordering
utf8CompareShortByteString :: ShortByteString -> ShortByteString -> Ordering
utf8EncodeByteArray# :: String -> ByteArray#
utf8EncodePtr :: Ptr Word8 -> String -> IO ()

-- | Encode a String into a ByteString.
utf8EncodeByteString :: String -> ByteString
utf8EncodeShortByteString :: String -> ShortByteString
utf8EncodedLength :: String -> Int

module GHC.Utils.Encoding
type UserString = String
type EncodedString = String
zEncodeString :: UserString -> EncodedString
zDecodeString :: EncodedString -> UserString
toBase62 :: Word64 -> String

-- | Converts a 64-bit word into a base-62 string
toBase62Padded :: Word64 -> String

-- | An Unicode string for internal GHC use. Meant to replace String in
--   places where being a lazy linked is not very useful and a more memory
--   efficient data structure is desirable.
module GHC.Data.ShortText

-- | A ShortText is a modified UTF-8 encoded string meant for short
--   strings like file paths, module descriptions, etc.
newtype ShortText
ShortText :: ShortByteString -> ShortText
[contents] :: ShortText -> ShortByteString

-- | Create a singleton
singleton :: Char -> ShortText

-- | O(n) Convert a String into a ShortText.
pack :: String -> ShortText

-- | O(n) Convert a ShortText into a String.
unpack :: ShortText -> String

-- | O(n) Returns the length of the ShortText in characters.
codepointLength :: ShortText -> Int

-- | O(1) Returns the length of the ShortText in bytes.
byteLength :: ShortText -> Int

-- | O(1) Test whether the ShortText is the empty string.
null :: ShortText -> Bool

-- | O(n) Split a ShortText representing a file path into its
--   components by separating on the file separator characters for this
--   platform.
splitFilePath :: ShortText -> [ShortText]

-- | O(1) Returns the first UTF-8 codepoint in the ShortText.
--   Depending on the string in question, this may or may not be the actual
--   first character in the string due to Unicode non-printable characters.
head :: ShortText -> Char

-- | O(n) The stripPrefix function takes two
--   ShortTexts and returns Just the remainder of the second
--   iff the first is its prefix, and otherwise Nothing.
stripPrefix :: ShortText -> ShortText -> Maybe ShortText
instance Data.Binary.Class.Binary GHC.Data.ShortText.ShortText
instance GHC.Classes.Eq GHC.Data.ShortText.ShortText
instance GHC.Internal.Data.String.IsString GHC.Data.ShortText.ShortText
instance GHC.Internal.Base.Monoid GHC.Data.ShortText.ShortText
instance Control.DeepSeq.NFData GHC.Data.ShortText.ShortText
instance GHC.Classes.Ord GHC.Data.ShortText.ShortText
instance GHC.Internal.Base.Semigroup GHC.Data.ShortText.ShortText
instance GHC.Internal.Show.Show GHC.Data.ShortText.ShortText

-- | 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 registered 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 database in
--   one file, one version used only by ghc-pkg which keeps the full
--   information (using the serialised form of the
--   InstalledPackageInfo 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.Unit.Database

-- | Information about an unit (a unit is an installed module library).
--   
--   This is a subset of Cabal's InstalledPackageInfo, with just
--   the bits that GHC is interested in.
--   
--   Some types are left as parameters to be instantiated differently in
--   ghc-pkg and in ghc itself.
data GenericUnitInfo srcpkgid srcpkgname uid modulename mod
GenericUnitInfo :: uid -> uid -> [(modulename, mod)] -> srcpkgid -> srcpkgname -> Version -> Maybe srcpkgname -> ShortText -> [uid] -> [(uid, ShortText)] -> [FilePathST] -> [ShortText] -> [ShortText] -> [ShortText] -> [FilePathST] -> [FilePathST] -> [ShortText] -> [FilePathST] -> [ShortText] -> [ShortText] -> [ShortText] -> [FilePathST] -> [FilePathST] -> [FilePathST] -> [(modulename, Maybe mod)] -> [modulename] -> Bool -> Bool -> Bool -> GenericUnitInfo srcpkgid srcpkgname uid modulename mod

-- | Unique unit identifier that is used during compilation (e.g. to
--   generate symbols).
[unitId] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> uid

-- | Identifier of an indefinite unit (i.e. with module holes) that this
--   unit is an instance of.
--   
--   For non instantiated units, unitInstanceOf=unitId
[unitInstanceOf] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> uid

-- | How this unit instantiates some of its module holes. Map hole module
--   names to actual module
[unitInstantiations] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [(modulename, mod)]

-- | Source package identifier.
--   
--   Cabal instantiates this with Distribution.Types.PackageId.PackageId
--   type which only contains the source package name and version. Notice
--   that it doesn't contain the Hackage revision, nor any kind of hash.
[unitPackageId] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> srcpkgid

-- | Source package name
[unitPackageName] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> srcpkgname

-- | Source package version
[unitPackageVersion] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> Version

-- | Name of the component.
--   
--   Cabal supports more than one components (libraries, executables,
--   testsuites) in the same package. Each component has a name except the
--   default one (that can only be a library component) for which we use
--   Nothing.
--   
--   GHC only deals with "library" components as they are the only kind of
--   components that can be registered in a database and used by other
--   modules.
[unitComponentName] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> Maybe srcpkgname

-- | ABI hash used to avoid mixing up units compiled with different
--   dependencies, compiler, options, etc.
[unitAbiHash] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> ShortText

-- | Identifiers of the units this one depends on
[unitDepends] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [uid]

-- | Like unitDepends, but each dependency is annotated with the ABI
--   hash we expect the dependency to respect.
[unitAbiDepends] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [(uid, ShortText)]

-- | Directories containing module interfaces
[unitImportDirs] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [FilePathST]

-- | Names of the Haskell libraries provided by this unit
[unitLibraries] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [ShortText]

-- | Names of the external system libraries that this unit depends on. See
--   also unitExtDepLibsGhc field.
[unitExtDepLibsSys] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [ShortText]

-- | Because of slight differences between the GHC dynamic linker (in
--   GHC.Runtime.Linker) and the native system linker, some packages have
--   to link with a different list of libraries when using GHC's. Examples
--   include: libs that are actually gnu ld scripts, and the possibility
--   that the .a libs do not exactly match the .so/.dll equivalents.
--   
--   If this field is set, then we use that instead of the
--   unitExtDepLibsSys field.
[unitExtDepLibsGhc] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [ShortText]

-- | Directories containing libraries provided by this unit. See also
--   unitLibraryDynDirs.
--   
--   It seems to be used to store paths to external library dependencies
--   too.
[unitLibraryDirs] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [FilePathST]

-- | Directories containing the dynamic libraries provided by this unit.
--   See also unitLibraryDirs.
--   
--   It seems to be used to store paths to external dynamic library
--   dependencies too.
[unitLibraryDynDirs] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [FilePathST]

-- | Names of the external MacOS frameworks that this unit depends on.
[unitExtDepFrameworks] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [ShortText]

-- | Directories containing MacOS frameworks that this unit depends on.
[unitExtDepFrameworkDirs] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [FilePathST]

-- | Linker (e.g. ld) command line options
[unitLinkerOptions] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [ShortText]

-- | C compiler options that needs to be passed to the C compiler when we
--   compile some C code against this unit.
[unitCcOptions] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [ShortText]

-- | C header files that are required by this unit (provided by this unit
--   or external)
[unitIncludes] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [ShortText]

-- | Directories containing C header files that this unit depends on.
[unitIncludeDirs] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [FilePathST]

-- | Paths to Haddock interface files for this unit
[unitHaddockInterfaces] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [FilePathST]

-- | Paths to Haddock directories containing HTML files
[unitHaddockHTMLs] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [FilePathST]

-- | Modules exposed by the unit.
--   
--   A module can be re-exported from another package. In this case, we
--   indicate the module origin in the second parameter.
[unitExposedModules] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [(modulename, Maybe mod)]

-- | Hidden modules.
--   
--   These are useful for error reporting (e.g. if a hidden module is
--   imported)
[unitHiddenModules] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> [modulename]

-- | True if this unit has some module holes that need to be instantiated
--   with real modules to make the unit usable (a.k.a. Backpack).
[unitIsIndefinite] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> Bool

-- | True if the unit is exposed. A unit could be installed in a database
--   by "disabled" by not being exposed.
[unitIsExposed] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> Bool

-- | True if the unit is trusted (cf Safe Haskell)
[unitIsTrusted] :: GenericUnitInfo srcpkgid srcpkgname uid modulename mod -> Bool

-- | ghc-boot's UnitInfo, serialized to the database.
type DbUnitInfo = GenericUnitInfo ByteString ByteString ByteString ByteString DbModule

-- | ghc-boot's Module, serialized to the database.
data DbModule
DbModule :: DbInstUnitId -> ByteString -> DbModule
[dbModuleUnitId] :: DbModule -> DbInstUnitId
[dbModuleName] :: DbModule -> ByteString
DbModuleVar :: ByteString -> DbModule
[dbModuleVarName] :: DbModule -> ByteString

-- | ghc-boot's instantiated unit id, serialized to the database.
data DbInstUnitId

-- | Instantiated unit
DbInstUnitId :: ByteString -> [(ByteString, DbModule)] -> DbInstUnitId

-- | Uninstantiated unit
DbUnitId :: ByteString -> DbInstUnitId

-- | Convert between GenericUnitInfo instances
mapGenericUnitInfo :: (uid1 -> uid2) -> (srcpkg1 -> srcpkg2) -> (srcpkgname1 -> srcpkgname2) -> (modname1 -> modname2) -> (mod1 -> mod2) -> GenericUnitInfo srcpkg1 srcpkgname1 uid1 modname1 mod1 -> GenericUnitInfo srcpkg2 srcpkgname2 uid2 modname2 mod2

-- | Mode to open a package db in.
data DbMode
DbReadOnly :: DbMode
DbReadWrite :: DbMode

-- | DbOpenMode holds a value of type t but only in
--   DbReadWrite mode. So it is like Maybe but with a type
--   argument for the mode to enforce that the mode is used consistently.
data DbOpenMode (mode :: DbMode) t
[DbOpenReadOnly] :: forall t. DbOpenMode 'DbReadOnly t
[DbOpenReadWrite] :: forall t. t -> DbOpenMode 'DbReadWrite t
isDbOpenReadMode :: forall (mode :: DbMode) t. DbOpenMode mode t -> Bool

-- | Read the part of the package DB that GHC is interested in.
readPackageDbForGhc :: FilePath -> IO [DbUnitInfo]

-- | 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.
--   
--   If we open the package db in read only mode, we get its contents.
--   Otherwise we additionally receive a PackageDbLock that represents a
--   lock on the database, so that we can safely update it later.
readPackageDbForGhcPkg :: forall pkgs (mode :: DbMode) t. Binary pkgs => FilePath -> DbOpenMode mode t -> IO (pkgs, DbOpenMode mode PackageDbLock)

-- | Write the whole of the package DB, both parts.
writePackageDb :: Binary pkgs => FilePath -> [DbUnitInfo] -> pkgs -> IO ()

-- | Represents a lock of a package db.
data PackageDbLock

-- | Acquire an exclusive lock related to package DB under given location.
lockPackageDb :: FilePath -> IO PackageDbLock

-- | Release the lock related to package DB.
unlockPackageDb :: PackageDbLock -> IO ()
mkMungePathUrl :: FilePathST -> FilePathST -> (FilePathST -> FilePathST, FilePathST -> FilePathST)

-- | Perform path/URL variable substitution as per the Cabal ${pkgroot}
--   spec
--   (http:/www.haskell.orgpipermaillibraries2009-May/011772.html)
--   Paths/URLs can be relative to ${pkgroot} or ${pkgrooturl}. The
--   "pkgroot" is the directory containing the package database.
--   
--   Also perform a similar substitution for the older GHC-specific
--   "$topdir" variable. The "topdir" is the location of the ghc
--   installation (obtained from the -B option).
mungeUnitInfoPaths :: FilePathST -> FilePathST -> GenericUnitInfo a b c d e -> GenericUnitInfo a b c d e
instance Data.Binary.Class.Binary GHC.Unit.Database.DbInstUnitId
instance Data.Binary.Class.Binary GHC.Unit.Database.DbModule
instance Data.Binary.Class.Binary GHC.Unit.Database.DbUnitInfo
instance GHC.Classes.Eq GHC.Unit.Database.DbInstUnitId
instance GHC.Classes.Eq GHC.Unit.Database.DbModule
instance (GHC.Classes.Eq uid, GHC.Classes.Eq modulename, GHC.Classes.Eq mod, GHC.Classes.Eq srcpkgid, GHC.Classes.Eq srcpkgname) => GHC.Classes.Eq (GHC.Unit.Database.GenericUnitInfo srcpkgid srcpkgname uid modulename mod)
instance GHC.Internal.Data.Foldable.Foldable (GHC.Unit.Database.DbOpenMode mode)
instance GHC.Internal.Base.Functor (GHC.Unit.Database.DbOpenMode mode)
instance GHC.Internal.Show.Show GHC.Unit.Database.DbInstUnitId
instance GHC.Internal.Show.Show GHC.Unit.Database.DbModule
instance (GHC.Internal.Show.Show uid, GHC.Internal.Show.Show modulename, GHC.Internal.Show.Show mod, GHC.Internal.Show.Show srcpkgid, GHC.Internal.Show.Show srcpkgname) => GHC.Internal.Show.Show (GHC.Unit.Database.GenericUnitInfo srcpkgid srcpkgname uid modulename mod)
instance GHC.Internal.Data.Traversable.Traversable (GHC.Unit.Database.DbOpenMode mode)

module GHC.Version
cProjectGitCommitId :: String
cProjectVersion :: String
cProjectVersionInt :: String
cProjectPatchLevel :: String
cProjectPatchLevel1 :: String
cProjectPatchLevel2 :: String

module GHC.UniqueSubdir

-- | A filepath like x86_64-linux-7.6.3 with the platform string
--   to use when constructing platform-version-dependent files that need to
--   co-exist.
uniqueSubdir :: ArchOS -> FilePath
