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

-- | Content addressable Haskell package management
--   
--   Please see the README on GitHub at
--   https://github.com/commercialhaskell/pantry#readme
@package pantry
@version 0.9.3.2

-- | Provides a data type (SHA256) for efficient memory
--   representation of a sha-256 hash value, together with helper functions
--   for converting to and from that value. This module is intended to be
--   imported qualified as SHA256.
--   
--   Some nomenclature:
--   
--   
--   
- Hashing calculates a new hash value from some input. from
--   takes a value that represents an existing hash.
--   
- Raw means a raw binary representation of the hash value, without
--   any hex encoding.
--   
- Text always uses lower case hex encoding
--   
module Pantry.SHA256

-- | A SHA256 hash, stored in a static size for more efficient memory
--   representation.
data SHA256

-- | Exceptions which can occur in this module
data SHA256Exception
InvalidByteCount :: !ByteString -> !StaticBytesException -> SHA256Exception
InvalidHexBytes :: !ByteString -> !Text -> SHA256Exception

-- | Generate a SHA256 value by hashing the contents of a file.
hashFile :: MonadIO m => FilePath -> m SHA256

-- | Generate a SHA256 value by hashing a ByteString.
hashBytes :: ByteString -> SHA256

-- | Generate a SHA256 value by hashing a lazy ByteString.
hashLazyBytes :: LByteString -> SHA256

-- | Generate a SHA256 value by hashing the contents of a stream.
sinkHash :: Monad m => ConduitT ByteString o m SHA256

-- | Convert a base16-encoded Text value containing a hash into a
--   SHA256.
fromHexText :: Text -> Either SHA256Exception SHA256

-- | Convert a base16-encoded ByteString value containing a hash
--   into a SHA256.
fromHexBytes :: ByteString -> Either SHA256Exception SHA256

-- | Convert a Digest into a SHA256
fromDigest :: Digest SHA256 -> SHA256

-- | Convert a raw representation of a hash into a SHA256.
fromRaw :: ByteString -> Either SHA256Exception SHA256

-- | Convert a SHA256 into a base16-encoded SHA256 hash.
toHexText :: SHA256 -> Text

-- | Convert a SHA256 into a base16-encoded SHA256 hash.
toHexBytes :: SHA256 -> ByteString

-- | Convert a SHA256 into a raw binary representation.
toRaw :: SHA256 -> ByteString
instance Data.Hashable.Class.Hashable Pantry.SHA256.SHA256
instance GHC.Classes.Ord Pantry.SHA256.SHA256
instance Data.Data.Data Pantry.SHA256.SHA256
instance Control.DeepSeq.NFData Pantry.SHA256.SHA256
instance GHC.Classes.Eq Pantry.SHA256.SHA256
instance GHC.Generics.Generic Pantry.SHA256.SHA256
instance GHC.Exception.Type.Exception Pantry.SHA256.SHA256Exception
instance GHC.Show.Show Pantry.SHA256.SHA256Exception
instance RIO.Prelude.Display.Display Pantry.SHA256.SHA256Exception
instance GHC.Show.Show Pantry.SHA256.SHA256
instance Database.Persist.Class.PersistField.PersistField Pantry.SHA256.SHA256
instance Database.Persist.Sql.Class.PersistFieldSql Pantry.SHA256.SHA256
instance RIO.Prelude.Display.Display Pantry.SHA256.SHA256
instance Data.Aeson.Types.ToJSON.ToJSON Pantry.SHA256.SHA256
instance Data.Aeson.Types.FromJSON.FromJSON Pantry.SHA256.SHA256

module Pantry.SQLite

-- | Represents a SQL database connection.
data Storage
Storage :: (forall env a. HasLogFunc env => ReaderT SqlBackend (RIO env) a -> RIO env a) -> (forall env a. HasLogFunc env => RIO env a -> RIO env a) -> Storage
[withStorage_] :: Storage -> forall env a. HasLogFunc env => ReaderT SqlBackend (RIO env) a -> RIO env a
[withWriteLock_] :: Storage -> forall env a. HasLogFunc env => RIO env a -> RIO env a
initStorage :: HasLogFunc env => Text -> Migration -> Path Abs File -> (Storage -> RIO env a) -> RIO env a

-- | All types and functions exported from this module are for advanced
--   usage only. They are needed for stackage-server integration with
--   pantry and some are needed for stack testing.
module Pantry.Internal.Stackage
data Version
data PackageName

-- | By default, a backend will automatically generate the key Instead you
--   can specify a Primary key made up of unique values.
data family Key record

-- | Unique keys besides the Key.
data family Unique record
data Tree
Tree :: !BlobId -> !Maybe BlobId -> !FileType -> !PackageNameId -> !VersionId -> Tree
[treeKey] :: Tree -> !BlobId
[treeCabal] :: Tree -> !Maybe BlobId
[treeCabalType] :: Tree -> !FileType
[treeName] :: Tree -> !PackageNameId
[treeVersion] :: Tree -> !VersionId

-- | An EntityField is parameterised by the Haskell record it
--   belongs to and the additional type of that field.
--   
--   As of persistent-2.11.0.0, it's possible to use the
--   OverloadedLabels language extension to refer to
--   EntityField values polymorphically. See the documentation on
--   SymbolToField for more information.
data family EntityField record :: Type -> Type

-- | Configuration value used by the entire pantry package. Create one
--   using withPantryConfig or withPantryConfig'. See
--   also PantryApp for a convenience approach to using pantry.
data PantryConfig
PantryConfig :: !PackageIndexConfig -> !HpackExecutable -> !Path Abs Dir -> !Storage -> !MVar Bool -> !IORef (Map RawPackageLocationImmutable GenericPackageDescription) -> !IORef (Map (Path Abs Dir) (PrintWarnings -> IO GenericPackageDescription, PackageName, Path Abs File)) -> !Int -> !Maybe (CasaRepoPrefix, Int) -> (SnapName -> RawSnapshotLocation) -> PantryConfig
[pcPackageIndex] :: PantryConfig -> !PackageIndexConfig
[pcHpackExecutable] :: PantryConfig -> !HpackExecutable
[pcRootDir] :: PantryConfig -> !Path Abs Dir
[pcStorage] :: PantryConfig -> !Storage

-- | Want to try updating the index once during a single run for missing
--   package identifiers. We also want to ensure we only update once at a
--   time. Start at True.
[pcUpdateRef] :: PantryConfig -> !MVar Bool

-- | Cache of previously parsed cabal files, to save on slow parsing time.
[pcParsedCabalFilesRawImmutable] :: PantryConfig -> !IORef (Map RawPackageLocationImmutable GenericPackageDescription)

-- | Cache for mutable packages. We want to allow for an optimization:
--   deferring parsing of the GenericPackageDescription until its
--   actually needed. Therefore, we keep the filepath and the
--   PackageName derived from that filepath. When the IO
--   GenericPackageDescription is run, it will ensure that the
--   PackageName matches the value inside the cabal file, and
--   print out any warnings that still need to be printed.
[pcParsedCabalFilesMutable] :: PantryConfig -> !IORef (Map (Path Abs Dir) (PrintWarnings -> IO GenericPackageDescription, PackageName, Path Abs File))

-- | concurrently open downloads
[pcConnectionCount] :: PantryConfig -> !Int

-- | Optionally, the Casa pull URL e.g.
--   https://casa.stackage.org and the maximum number of
--   Casa keys to pull per request.
[pcCasaConfig] :: PantryConfig -> !Maybe (CasaRepoPrefix, Int)

-- | The location of snapshot synonyms
[pcSnapshotLocation] :: PantryConfig -> SnapName -> RawSnapshotLocation
data SafeFilePath

-- | Represents a SQL database connection.
data Storage
Storage :: (forall env a. HasLogFunc env => ReaderT SqlBackend (RIO env) a -> RIO env a) -> (forall env a. HasLogFunc env => RIO env a -> RIO env a) -> Storage
[withStorage_] :: Storage -> forall env a. HasLogFunc env => ReaderT SqlBackend (RIO env) a -> RIO env a
[withWriteLock_] :: Storage -> forall env a. HasLogFunc env => RIO env a -> RIO env a

-- | Information returned by getHackageTarball
data HackageTarballResult
HackageTarballResult :: !Package -> !Maybe (GenericPackageDescription, TreeId) -> HackageTarballResult

-- | Package that was loaded from Hackage tarball
[htrPackage] :: HackageTarballResult -> !Package

-- | This information is only available whenever package was just loaded
--   into pantry.
[htrFreshPackageInfo] :: HackageTarballResult -> !Maybe (GenericPackageDescription, TreeId)
type BlobId = Key Blob
type HackageCabalId = Key HackageCabal
type ModuleNameId = Key ModuleName
type PackageNameId = Key PackageName
type TreeEntryId = Key TreeEntry
type TreeId = Key Tree
type VersionId = Key Version
newtype ModuleNameP
ModuleNameP :: ModuleName -> ModuleNameP
[unModuleNameP] :: ModuleNameP -> ModuleName
newtype PackageNameP
PackageNameP :: PackageName -> PackageNameP
[unPackageNameP] :: PackageNameP -> PackageName
newtype VersionP
VersionP :: Version -> VersionP
[unVersionP] :: VersionP -> Version
mkSafeFilePath :: Text -> Maybe SafeFilePath
getHackageTarball :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => PackageIdentifierRevision -> Maybe TreeKey -> RIO env HackageTarballResult
getTreeForKey :: TreeKey -> ReaderT SqlBackend (RIO env) (Maybe (Entity Tree))
unSafeFilePath :: SafeFilePath -> Text

-- | Same as updateHackageIndex, but force the database update even
--   if hackage security tells that there is no change. This can be useful
--   in order to make sure the database is in sync with the locally
--   downloaded tarball
forceUpdateHackageIndex :: (HasPantryConfig env, HasLogFunc env) => Maybe Utf8Builder -> RIO env DidUpdateOccur
allBlobsCount :: Maybe BlobId -> ReaderT SqlBackend (RIO env) Int
allBlobsSource :: HasResourceMap env => Maybe BlobId -> ConduitT () (BlobId, ByteString) (ReaderT SqlBackend (RIO env)) ()
allHackageCabalCount :: Maybe HackageCabalId -> ReaderT SqlBackend (RIO env) Int

-- | Pull all hackage cabal entries from the database as
--   RawPackageLocationImmutable. We do a manual join rather than
--   dropping to raw SQL, and Esqueleto would add more deps.
allHackageCabalRawPackageLocations :: HasResourceMap env => Maybe HackageCabalId -> ReaderT SqlBackend (RIO env) (Map HackageCabalId RawPackageLocationImmutable)
getBlobKey :: BlobId -> ReaderT SqlBackend (RIO env) BlobKey
getPackageNameById :: PackageNameId -> ReaderT SqlBackend (RIO env) (Maybe PackageName)
getPackageNameId :: PackageName -> ReaderT SqlBackend (RIO env) PackageNameId
getVersionId :: Version -> ReaderT SqlBackend (RIO env) VersionId
loadBlobById :: BlobId -> ReaderT SqlBackend (RIO env) ByteString
migrateAll :: Migration
storeBlob :: ByteString -> ReaderT SqlBackend (RIO env) (BlobId, BlobKey)

-- | The TreeKey containing this package.
--   
--   This is a hash of the binary representation of packageTree.
packageTreeKey :: Package -> TreeKey

-- | Content addressable Haskell package management, providing for secure,
--   reproducible acquisition of Haskell package contents and metadata.
module Pantry

-- | Configuration value used by the entire pantry package. Create one
--   using withPantryConfig or withPantryConfig'. See
--   also PantryApp for a convenience approach to using pantry.
data PantryConfig

-- | Configuration to securely download package metadata and contents. For
--   most purposes, you'll want to use the default Hackage settings via
--   defaultPackageIndexConfig.
--   
--   NOTE It's highly recommended to only use the official Hackage
--   server or a mirror. See
--   https://github.com/commercialhaskell/stack/issues/4137.
data PackageIndexConfig
PackageIndexConfig :: !Text -> !HackageSecurityConfig -> PackageIndexConfig
[picDownloadPrefix] :: PackageIndexConfig -> !Text
[picHackageSecurityConfig] :: PackageIndexConfig -> !HackageSecurityConfig

-- | Configuration for Hackage Security to securely download package
--   metadata and contents. For most purposes, you'll want to use the
--   default Hackage settings via defaultHackageSecurityConfig.
--   
--   NOTE It's highly recommended to only use the official Hackage
--   server or a mirror. See
--   https://github.com/commercialhaskell/stack/issues/4137.
data HackageSecurityConfig
HackageSecurityConfig :: ![Text] -> !Int -> !Bool -> HackageSecurityConfig
[hscKeyIds] :: HackageSecurityConfig -> ![Text]
[hscKeyThreshold] :: HackageSecurityConfig -> !Int
[hscIgnoreExpiry] :: HackageSecurityConfig -> !Bool

-- | Default PackageIndexConfig value using the official Hackage
--   server.
defaultPackageIndexConfig :: PackageIndexConfig

-- | The download prefix for the official Hackage server.
defaultDownloadPrefix :: Text

-- | Default HackageSecurityConfig value using the official Hackage
--   server. The value of the hscIgnoreExpiry field is True.
defaultHackageSecurityConfig :: HackageSecurityConfig

-- | Default pull URL for Casa.
defaultCasaRepoPrefix :: CasaRepoPrefix

-- | Default max keys to pull per request.
defaultCasaMaxPerRequest :: Int

-- | Default location of snapshot synonyms, i.e. commercialhaskell's GitHub
--   repository.
defaultSnapshotLocation :: SnapName -> RawSnapshotLocation

-- | An environment which contains a PantryConfig.
class HasPantryConfig env

-- | Lens to get or set the PantryConfig
pantryConfigL :: HasPantryConfig env => Lens' env PantryConfig

-- | Create a new PantryConfig with the given settings. For a
--   version where the use of Casa (content-addressable storage archive) is
--   optional, see withPantryConfig'.
--   
--   For something easier to use in simple cases, see runPantryApp.
withPantryConfig :: HasLogFunc env => Path Abs Dir -> PackageIndexConfig -> HpackExecutable -> Int -> CasaRepoPrefix -> Int -> (SnapName -> RawSnapshotLocation) -> (PantryConfig -> RIO env a) -> RIO env a

-- | Create a new PantryConfig with the given settings.
--   
--   For something easier to use in simple cases, see runPantryApp.
withPantryConfig' :: HasLogFunc env => Path Abs Dir -> PackageIndexConfig -> HpackExecutable -> Int -> Maybe (CasaRepoPrefix, Int) -> (SnapName -> RawSnapshotLocation) -> (PantryConfig -> RIO env a) -> RIO env a

-- | What to use for running hpack
data HpackExecutable

-- | Compiled in library
HpackBundled :: HpackExecutable

-- | Executable at the provided path
HpackCommand :: !FilePath -> HpackExecutable

-- | Convenient data type that allows you to work with pantry more easily
--   than using withPantryConfig or withPantryConfig'
--   directly. Uses basically sane settings, like sharing a pantry
--   directory with Stack.
--   
--   You can use runPantryApp to use this. A simple example is:
--   
--   
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   module Main (main) where
--   
--   -- From package Cabal-syntax
--   import Distribution.Types.Version ( mkVersion )
--   -- From package pantry
--   import Pantry
--            ( CabalFileInfo (..), PackageIdentifierRevision (..), PantryApp
--            , RawPackageLocationImmutable (..), loadPackageRaw, runPantryApp
--            )
--   -- From package rio
--   import RIO ( RIO, liftIO )
--   
--   main :: IO ()
--   main = runPantryApp myPantryApp
--   
--   myPantryApp :: RIO PantryApp ()
--   myPantryApp = loadPackageRaw baseLocation >>= liftIO . print
--    where
--     baseVersion = mkVersion [4, 19, 0, 0]
--     basePkgId = PackageIdentifierRevision "base" baseVersion CFILatest
--     baseLocation = RPLIHackage basePkgId Nothing
--   
data PantryApp

-- | Run some code against pantry using basic sane settings.
--   
--   For testing, see runPantryAppClean.
runPantryApp :: MonadIO m => RIO PantryApp a -> m a

-- | Like runPantryApp, but uses an empty pantry directory instead
--   of sharing with Stack. Useful for testing.
runPantryAppClean :: MonadIO m => RIO PantryApp a -> m a

-- | Run some code against pantry using basic sane settings.
--   
--   For testing, see runPantryAppClean.
runPantryAppWith :: MonadIO m => Int -> CasaRepoPrefix -> Int -> RIO PantryApp a -> m a

-- | Lens to view or modify the HpackExecutable of a
--   PantryConfig
hpackExecutableL :: Lens' PantryConfig HpackExecutable

-- | Things that can go wrong in pantry. Note two things:
--   
--   
--   
- Many other exception types may be thrown from underlying
--   libraries. Pantry does not attempt to wrap these underlying
--   exceptions.
--   
- We may add more constructors to this data type in minor version
--   bumps of pantry. This technically breaks the PVP. You should not be
--   writing pattern matches against this type that expect total
--   matching.
--   
data PantryException
PackageIdentifierRevisionParseFail :: !Text -> PantryException
InvalidCabalFile :: !Either RawPackageLocationImmutable (Path Abs File) -> !Maybe Version -> ![PError] -> ![PWarning] -> PantryException
TreeWithoutCabalFile :: !RawPackageLocationImmutable -> PantryException
TreeWithMultipleCabalFiles :: !RawPackageLocationImmutable -> ![SafeFilePath] -> PantryException
MismatchedCabalName :: !Path Abs File -> !PackageName -> PantryException
NoLocalPackageDirFound :: !Path Abs Dir -> PantryException
NoCabalFileFound :: !Path Abs Dir -> PantryException
MultipleCabalFilesFound :: !Path Abs Dir -> ![Path Abs File] -> PantryException
InvalidWantedCompiler :: !Text -> PantryException
InvalidSnapshotLocation :: !Path Abs Dir -> !Text -> PantryException
InvalidOverrideCompiler :: !WantedCompiler -> !WantedCompiler -> PantryException
InvalidFilePathSnapshot :: !Text -> PantryException
InvalidSnapshot :: !RawSnapshotLocation -> !SomeException -> PantryException
MismatchedPackageMetadata :: !RawPackageLocationImmutable -> !RawPackageMetadata -> !Maybe TreeKey -> !PackageIdentifier -> PantryException
Non200ResponseStatus :: !Status -> PantryException
InvalidBlobKey :: !Mismatch BlobKey -> PantryException
Couldn'tParseSnapshot :: !RawSnapshotLocation -> !String -> PantryException
WrongCabalFileName :: !RawPackageLocationImmutable -> !SafeFilePath -> !PackageName -> PantryException
DownloadInvalidSHA256 :: !Text -> !Mismatch SHA256 -> PantryException
DownloadInvalidSize :: !Text -> !Mismatch FileSize -> PantryException

-- | Different from DownloadInvalidSize since mismatchActual
--   is a lower bound on the size from the server.
DownloadTooLarge :: !Text -> !Mismatch FileSize -> PantryException
LocalNoArchiveFileFound :: !Path Abs File -> PantryException
LocalInvalidSHA256 :: !Path Abs File -> !Mismatch SHA256 -> PantryException
LocalInvalidSize :: !Path Abs File -> !Mismatch FileSize -> PantryException
UnknownArchiveType :: !ArchiveLocation -> PantryException
InvalidTarFileType :: !ArchiveLocation -> !FilePath -> !FileType -> PantryException
UnsupportedTarball :: !ArchiveLocation -> !Text -> PantryException
NoHackageCryptographicHash :: !PackageIdentifier -> PantryException
FailedToCloneRepo :: !SimpleRepo -> PantryException
TreeReferencesMissingBlob :: !RawPackageLocationImmutable -> !SafeFilePath -> !BlobKey -> PantryException
CompletePackageMetadataMismatch :: !RawPackageLocationImmutable -> !PackageMetadata -> PantryException
CRC32Mismatch :: !ArchiveLocation -> !FilePath -> !Mismatch Word32 -> PantryException
UnknownHackagePackage :: !PackageIdentifierRevision -> !FuzzyResults -> PantryException
CannotCompleteRepoNonSHA1 :: !Repo -> PantryException
MutablePackageLocationFromUrl :: !Text -> PantryException
MismatchedCabalFileForHackage :: !PackageIdentifierRevision -> !Mismatch PackageIdentifier -> PantryException
PackageNameParseFail :: !Text -> PantryException
PackageVersionParseFail :: !Text -> PantryException
InvalidCabalFilePath :: !Path Abs File -> PantryException
DuplicatePackageNames :: !Utf8Builder -> ![(PackageName, [RawPackageLocationImmutable])] -> PantryException
MigrationFailure :: !Text -> !Path Abs File -> !SomeException -> PantryException
NoCasaConfig :: PantryException
InvalidTreeFromCasa :: !BlobKey -> !ByteString -> PantryException
ParseSnapNameException :: !Text -> PantryException
HpackLibraryException :: !Path Abs File -> !String -> PantryException
HpackExeException :: !FilePath -> !Path Abs Dir -> !SomeException -> PantryException
data Mismatch a
Mismatch :: !a -> !a -> Mismatch a
[mismatchExpected] :: Mismatch a -> !a
[mismatchActual] :: Mismatch a -> !a
data FuzzyResults
FRNameNotFound :: ![PackageName] -> FuzzyResults
FRVersionNotFound :: !NonEmpty PackageIdentifierRevision -> FuzzyResults
FRRevisionNotFound :: !NonEmpty PackageIdentifierRevision -> FuzzyResults

-- | A package name.
--   
--   Use mkPackageName and unPackageName to convert from/to a
--   String.
--   
--   This type is opaque since Cabal-2.0
data () => PackageName

-- | A Version represents the version of a software entity.
--   
--   Instances of Eq and Ord are provided, which gives exact
--   equality and lexicographic ordering of the version number components
--   (i.e. 2.1 > 2.0, 1.2.3 > 1.2.2, etc.).
--   
--   This type is opaque and distinct from the Version type in
--   Data.Version since Cabal-2.0. The difference extends
--   to the Binary instance using a different (and more compact)
--   encoding.
data () => Version

-- | A FlagName is the name of a user-defined configuration flag
--   
--   Use mkFlagName and unFlagName to convert from/to a
--   String.
--   
--   This type is opaque since Cabal-2.0
data () => FlagName

-- | The name and version of a package.
data () => PackageIdentifier
PackageIdentifier :: PackageName -> Version -> PackageIdentifier

-- | The name of this package, eg. foo
[pkgName] :: PackageIdentifier -> PackageName

-- | the version of this package, eg 1.2
[pkgVersion] :: PackageIdentifier -> Version

-- | File size in bytes
newtype FileSize
FileSize :: Word -> FileSize

-- | File path relative to the configuration file it was parsed from
newtype RelFilePath
RelFilePath :: Text -> RelFilePath

-- | A combination of the relative path provided in a config file, together
--   with the resolved absolute path.
data ResolvedPath t
ResolvedPath :: !RelFilePath -> !Path Abs t -> ResolvedPath t

-- | Original value parsed from a config file.
[resolvedRelative] :: ResolvedPath t -> !RelFilePath

-- | Absolute path resolved against base directory loaded from.
[resolvedAbsolute] :: ResolvedPath t -> !Path Abs t

-- | Wraps a value which potentially contains relative paths. Needs to be
--   provided with a base directory to resolve these paths.
--   
--   Unwrap this using resolvePaths.
data Unresolved a
data SafeFilePath
mkSafeFilePath :: Text -> Maybe SafeFilePath

-- | A SHA256 hash, stored in a static size for more efficient memory
--   representation.
data SHA256

-- | The hash of the binary representation of a Tree.
newtype TreeKey
TreeKey :: BlobKey -> TreeKey

-- | A key for looking up a blob, which combines the SHA256 hash of the
--   contents and the file size.
--   
--   The file size may seem redundant with the hash. However, it is
--   necessary for safely downloading blobs from an untrusted source. See
--   https://www.fpcomplete.com/blog/2018/07/pantry-part-2-trees-keys.
data BlobKey
BlobKey :: !SHA256 -> !FileSize -> BlobKey

-- | Metadata provided by a config file for archives and repos. This
--   information can be used for optimized lookups of information like
--   package identifiers, or for validating that the user configuration has
--   the expected information.
data RawPackageMetadata
RawPackageMetadata :: !Maybe PackageName -> !Maybe Version -> !Maybe TreeKey -> RawPackageMetadata

-- | Package name in the cabal file
[rpmName] :: RawPackageMetadata -> !Maybe PackageName

-- | Package version in the cabal file
[rpmVersion] :: RawPackageMetadata -> !Maybe Version

-- | Tree key of the loaded up package
[rpmTreeKey] :: RawPackageMetadata -> !Maybe TreeKey

-- | Exact metadata specifying concrete package
data PackageMetadata
PackageMetadata :: !PackageIdentifier -> !TreeKey -> PackageMetadata

-- | Package identifier in the cabal file
[pmIdent] :: PackageMetadata -> !PackageIdentifier

-- | Tree key of the loaded up package
[pmTreeKey] :: PackageMetadata -> !TreeKey

-- | Parsed tree with more information on the Haskell package it contains.
data Package
Package :: !TreeKey -> !Tree -> !PackageCabal -> !PackageIdentifier -> Package

-- | The TreeKey containing this package.
--   
--   This is a hash of the binary representation of packageTree.
[packageTreeKey] :: Package -> !TreeKey

-- | The Tree containing this package.
[packageTree] :: Package -> !Tree

-- | Information on the cabal file inside this package.
[packageCabalEntry] :: Package -> !PackageCabal

-- | The package name and version in this package.
[packageIdent] :: Package -> !PackageIdentifier

-- | How to choose a cabal file for a package from Hackage. This is to work
--   with Hackage cabal file revisions, which makes
--   PackageIdentifier insufficient for specifying a package from
--   Hackage.
data CabalFileInfo

-- | Take the latest revision of the cabal file available. This isn't
--   reproducible at all, but the running assumption (not necessarily true)
--   is that cabal file revisions do not change semantics of the build.
CFILatest :: CabalFileInfo

-- | Identify by contents of the cabal file itself. Only reason for
--   Maybe on FileSize is for compatibility with input
--   that doesn't include the file size.
CFIHash :: !SHA256 -> !Maybe FileSize -> CabalFileInfo

-- | Identify by revision number, with 0 being the original and counting
--   upward. This relies on Hackage providing consistent versioning.
--   CFIHash should be preferred wherever possible for
--   reproducibility.
CFIRevision :: !Revision -> CabalFileInfo

-- | The revision number of a package from Hackage, counting upwards from 0
--   (the original cabal file).
--   
--   See caveats on CFIRevision.
newtype Revision
Revision :: Word -> Revision

-- | A full specification for a package from Hackage, including the package
--   name, version, and how to load up the correct cabal file revision.
data PackageIdentifierRevision
PackageIdentifierRevision :: !PackageName -> !Version -> !CabalFileInfo -> PackageIdentifierRevision

-- | Should we pay attention to Hackage's preferred versions?
data UsePreferredVersions
UsePreferredVersions :: UsePreferredVersions
IgnorePreferredVersions :: UsePreferredVersions

-- | A raw package archive, specified by a user, could have no hash and
--   file size information.
data RawArchive
RawArchive :: !ArchiveLocation -> !Maybe SHA256 -> !Maybe FileSize -> !Text -> RawArchive

-- | Location of the archive
[raLocation] :: RawArchive -> !ArchiveLocation

-- | Cryptographic hash of the archive file
[raHash] :: RawArchive -> !Maybe SHA256

-- | Size of the archive file
[raSize] :: RawArchive -> !Maybe FileSize

-- | Subdirectory within the archive to get the package from.
[raSubdir] :: RawArchive -> !Text

-- | A package archive, could be from a URL or a local file path. Local
--   file path archives are assumed to be unchanging over time, and so are
--   allowed in custom snapshots.
data Archive
Archive :: !ArchiveLocation -> !SHA256 -> !FileSize -> !Text -> Archive

-- | Location of the archive
[archiveLocation] :: Archive -> !ArchiveLocation

-- | Cryptographic hash of the archive file
[archiveHash] :: Archive -> !SHA256

-- | Size of the archive file
[archiveSize] :: Archive -> !FileSize

-- | Subdirectory within the archive to get the package from.
[archiveSubdir] :: Archive -> !Text

-- | Location that an archive is stored at
data ArchiveLocation

-- | Archive stored at an HTTP(S) URL
ALUrl :: !Text -> ArchiveLocation

-- | Archive stored at a local file path
ALFilePath :: !ResolvedPath File -> ArchiveLocation

-- | Information on packages stored in a source control repository.
data Repo
Repo :: !Text -> !Text -> !RepoType -> !Text -> Repo

-- | Location of the repo
[repoUrl] :: Repo -> !Text

-- | Commit to use from the repo. It's strongly recommended to use a hash
--   instead of a tag or branch name.
[repoCommit] :: Repo -> !Text

-- | The type of the repo
[repoType] :: Repo -> !RepoType

-- | Subdirectory within the archive to get the package from.
[repoSubdir] :: Repo -> !Text

-- | The type of a source control repository.
data RepoType
RepoGit :: RepoType
RepoHg :: RepoType

-- | Repository without subdirectory information.
data SimpleRepo
SimpleRepo :: !Text -> !Text -> !RepoType -> SimpleRepo
[sRepoUrl] :: SimpleRepo -> !Text
[sRepoCommit] :: SimpleRepo -> !Text
[sRepoType] :: SimpleRepo -> !RepoType

-- | Clone the repository (and, in the case of Git and if necessary, fetch
--   the specific commit) and execute the action with the working directory
--   set to the repository root.
withRepo :: forall env a. (HasLogFunc env, HasProcessContext env) => SimpleRepo -> RIO env a -> RIO env a

-- | Fetch the given repositories at once and populate the pantry database.
fetchRepos :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => [(Repo, PackageMetadata)] -> RIO env ()

-- | Like fetchRepos, except with RawPackageMetadata instead
--   of PackageMetadata.
fetchReposRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => [(Repo, RawPackageMetadata)] -> RIO env ()

-- | Location to load a package from. Can either be immutable (see
--   PackageLocationImmutable) or a local directory which is
--   expected to change over time. Raw version doesn't include exact
--   package version (e.g. could refer to the latest revision on Hackage)
data RawPackageLocation
RPLImmutable :: !RawPackageLocationImmutable -> RawPackageLocation
RPLMutable :: !ResolvedPath Dir -> RawPackageLocation

-- | Location to load a package from. Can either be immutable (see
--   PackageLocationImmutable) or a local directory which is
--   expected to change over time.
data PackageLocation
PLImmutable :: !PackageLocationImmutable -> PackageLocation
PLMutable :: !ResolvedPath Dir -> PackageLocation

-- | Convert PackageLocation to its "raw" equivalent
toRawPL :: PackageLocation -> RawPackageLocation

-- | Location for remote packages or archives assumed to be immutable. as
--   user specifies it i.e. not an exact location
data RawPackageLocationImmutable
RPLIHackage :: !PackageIdentifierRevision -> !Maybe TreeKey -> RawPackageLocationImmutable
RPLIArchive :: !RawArchive -> !RawPackageMetadata -> RawPackageLocationImmutable
RPLIRepo :: !Repo -> !RawPackageMetadata -> RawPackageLocationImmutable

-- | Location for remote packages or archives assumed to be immutable.
data PackageLocationImmutable
PLIHackage :: !PackageIdentifier -> !BlobKey -> !TreeKey -> PackageLocationImmutable
PLIArchive :: !Archive -> !PackageMetadata -> PackageLocationImmutable
PLIRepo :: !Repo -> !PackageMetadata -> PackageLocationImmutable

-- | Where to load a snapshot from in raw form (RSUrl could have a missing
--   BlobKey)
data RawSnapshotLocation

-- | Don't use an actual snapshot, just a version of the compiler with its
--   shipped packages.
RSLCompiler :: !WantedCompiler -> RawSnapshotLocation

-- | Download the snapshot from the given URL. The optional BlobKey
--   is used for reproducibility.
RSLUrl :: !Text -> !Maybe BlobKey -> RawSnapshotLocation

-- | Snapshot at a local file path.
RSLFilePath :: !ResolvedPath File -> RawSnapshotLocation

-- | Snapshot synonym (LTS/Nightly).
RSLSynonym :: !SnapName -> RawSnapshotLocation

-- | Where to load a snapshot from.
data SnapshotLocation

-- | Don't use an actual snapshot, just a version of the compiler with its
--   shipped packages.
SLCompiler :: !WantedCompiler -> SnapshotLocation

-- | Download the snapshot from the given URL. The optional BlobKey
--   is used for reproducibility.
SLUrl :: !Text -> !BlobKey -> SnapshotLocation

-- | Snapshot at a local file path.
SLFilePath :: !ResolvedPath File -> SnapshotLocation

-- | Convert snapshot location to its "raw" equivalent.
toRawSL :: SnapshotLocation -> RawSnapshotLocation

-- | A flattened representation of all the layers in a snapshot.
data RawSnapshot
RawSnapshot :: !WantedCompiler -> !Map PackageName RawSnapshotPackage -> !Set PackageName -> RawSnapshot

-- | The compiler wanted for this snapshot.
[rsCompiler] :: RawSnapshot -> !WantedCompiler

-- | Packages available in this snapshot for installation. This will be
--   applied on top of any globally available packages.
[rsPackages] :: RawSnapshot -> !Map PackageName RawSnapshotPackage

-- | Global packages that should be dropped/ignored.
[rsDrop] :: RawSnapshot -> !Set PackageName

-- | A flattened representation of all the layers in a snapshot.
data Snapshot
Snapshot :: !WantedCompiler -> !Map PackageName SnapshotPackage -> !Set PackageName -> Snapshot

-- | The compiler wanted for this snapshot.
[snapshotCompiler] :: Snapshot -> !WantedCompiler

-- | Packages available in this snapshot for installation. This will be
--   applied on top of any globally available packages.
[snapshotPackages] :: Snapshot -> !Map PackageName SnapshotPackage

-- | Global packages that should be dropped/ignored.
[snapshotDrop] :: Snapshot -> !Set PackageName

-- | Settings for a package found in a snapshot.
data RawSnapshotPackage
RawSnapshotPackage :: !RawPackageLocationImmutable -> !Map FlagName Bool -> !Bool -> ![Text] -> RawSnapshotPackage

-- | Where to get the package from
[rspLocation] :: RawSnapshotPackage -> !RawPackageLocationImmutable

-- | Same as slFlags
[rspFlags] :: RawSnapshotPackage -> !Map FlagName Bool

-- | Same as slHidden
[rspHidden] :: RawSnapshotPackage -> !Bool

-- | Same as slGhcOptions
[rspGhcOptions] :: RawSnapshotPackage -> ![Text]

-- | Settings for a package found in a snapshot.
data SnapshotPackage
SnapshotPackage :: !PackageLocationImmutable -> !Map FlagName Bool -> !Bool -> ![Text] -> SnapshotPackage

-- | Where to get the package from
[spLocation] :: SnapshotPackage -> !PackageLocationImmutable

-- | Same as slFlags
[spFlags] :: SnapshotPackage -> !Map FlagName Bool

-- | Same as slHidden
[spHidden] :: SnapshotPackage -> !Bool

-- | Same as slGhcOptions
[spGhcOptions] :: SnapshotPackage -> ![Text]

-- | A single layer of a snapshot, i.e. a specific YAML configuration file.
data RawSnapshotLayer
RawSnapshotLayer :: !RawSnapshotLocation -> !Maybe WantedCompiler -> ![RawPackageLocationImmutable] -> !Set PackageName -> !Map PackageName (Map FlagName Bool) -> !Map PackageName Bool -> !Map PackageName [Text] -> !Maybe UTCTime -> RawSnapshotLayer

-- | The sl to extend from. This is either a specific compiler, or a
--   SnapshotLocation which gives us more information (like
--   packages). Ultimately, we'll end up with a CompilerVersion.
[rslParent] :: RawSnapshotLayer -> !RawSnapshotLocation

-- | Override the compiler specified in slParent. Must be
--   Nothing if using SLCompiler.
[rslCompiler] :: RawSnapshotLayer -> !Maybe WantedCompiler

-- | Where to grab all of the packages from.
[rslLocations] :: RawSnapshotLayer -> ![RawPackageLocationImmutable]

-- | Packages present in the parent which should not be included here.
[rslDropPackages] :: RawSnapshotLayer -> !Set PackageName

-- | Flag values to override from the defaults
[rslFlags] :: RawSnapshotLayer -> !Map PackageName (Map FlagName Bool)

-- | Packages which should be hidden when registering. This will affect,
--   for example, the import parser in the script command. We use a
--   Map instead of just a Set to allow overriding the hidden
--   settings in a parent sl.
[rslHidden] :: RawSnapshotLayer -> !Map PackageName Bool

-- | GHC options per package
[rslGhcOptions] :: RawSnapshotLayer -> !Map PackageName [Text]

-- | See slPublishTime
[rslPublishTime] :: RawSnapshotLayer -> !Maybe UTCTime

-- | A single layer of a snapshot, i.e. a specific YAML configuration file.
data SnapshotLayer
SnapshotLayer :: !SnapshotLocation -> !Maybe WantedCompiler -> ![PackageLocationImmutable] -> !Set PackageName -> !Map PackageName (Map FlagName Bool) -> !Map PackageName Bool -> !Map PackageName [Text] -> !Maybe UTCTime -> SnapshotLayer

-- | The sl to extend from. This is either a specific compiler, or a
--   SnapshotLocation which gives us more information (like
--   packages). Ultimately, we'll end up with a CompilerVersion.
[slParent] :: SnapshotLayer -> !SnapshotLocation

-- | Override the compiler specified in slParent. Must be
--   Nothing if using SLCompiler.
[slCompiler] :: SnapshotLayer -> !Maybe WantedCompiler

-- | Where to grab all of the packages from.
[slLocations] :: SnapshotLayer -> ![PackageLocationImmutable]

-- | Packages present in the parent which should not be included here.
[slDropPackages] :: SnapshotLayer -> !Set PackageName

-- | Flag values to override from the defaults
[slFlags] :: SnapshotLayer -> !Map PackageName (Map FlagName Bool)

-- | Packages which should be hidden when registering. This will affect,
--   for example, the import parser in the script command. We use a
--   Map instead of just a Set to allow overriding the hidden
--   settings in a parent sl.
[slHidden] :: SnapshotLayer -> !Map PackageName Bool

-- | GHC options per package
[slGhcOptions] :: SnapshotLayer -> !Map PackageName [Text]

-- | Publication timestamp for this snapshot. This field is optional, and
--   is for informational purposes only.
[slPublishTime] :: SnapshotLayer -> !Maybe UTCTime

-- | Convert snapshot layer into its "raw" equivalent.
toRawSnapshotLayer :: SnapshotLayer -> RawSnapshotLayer

-- | Which compiler a snapshot wants to use. The build tool may elect to do
--   some fuzzy matching of versions (e.g., allowing different patch
--   versions).
data WantedCompiler
WCGhc :: !Version -> WantedCompiler
WCGhcGit :: !Text -> !Text -> WantedCompiler

-- | GHCJS version followed by GHC version
WCGhcjs :: !Version -> !Version -> WantedCompiler

-- | A snapshot synonym. It is expanded according to the field
--   snapshotLocation of a PantryConfig.
--   
--   @ since 0.5.0.0
data SnapName
LTS :: !Int -> !Int -> SnapName

-- | Stackage Nightly snapshot, displayed as "nighly-YYYY-MM-DD".
Nightly :: !Day -> SnapName

-- | Get the location of a snapshot synonym from the PantryConfig.
snapshotLocation :: HasPantryConfig env => SnapName -> RIO env RawSnapshotLocation

-- | Resolve all of the file paths in an Unresolved relative to the
--   given directory.
resolvePaths :: MonadIO m => Maybe (Path Abs Dir) -> Unresolved a -> m a

-- | Load a Package from a RawPackageLocationImmutable.
--   
--   Load the package either from the local DB, Casa, or as a last resort,
--   the third party (hackage, archive or repo).
loadPackageRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env Package

-- | Maybe load the package from Casa.
tryLoadPackageRawViaCasa :: (HasLogFunc env, HasPantryConfig env, HasProcessContext env) => RawPackageLocationImmutable -> TreeKey -> RIO env (Maybe Package)

-- | Load a Package from a PackageLocationImmutable.
loadPackage :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => PackageLocationImmutable -> RIO env Package

-- | Parse a SnapshotLayer value from a SnapshotLocation.
--   
--   Returns a Left value if provided an SLCompiler
--   constructor. Otherwise, returns a Right value providing both
--   the Snapshot and a hash of the input configuration file.
loadRawSnapshotLayer :: (HasPantryConfig env, HasLogFunc env) => RawSnapshotLocation -> RIO env (Either WantedCompiler (RawSnapshotLayer, CompletedSL))

-- | Parse a SnapshotLayer value from a SnapshotLocation.
--   
--   Returns a Left value if provided an SLCompiler
--   constructor. Otherwise, returns a Right value providing both
--   the Snapshot and a hash of the input configuration file.
loadSnapshotLayer :: (HasPantryConfig env, HasLogFunc env) => SnapshotLocation -> RIO env (Either WantedCompiler RawSnapshotLayer)

-- | Parse a RawSnapshot (all layers) from a
--   SnapshotLocation.
loadSnapshot :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => SnapshotLocation -> RIO env RawSnapshot

-- | Parse a Snapshot (all layers) from a SnapshotLocation
--   noting any incomplete package locations. Debug output will include the
--   raw snapshot layer.
loadAndCompleteSnapshot :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => SnapshotLocation -> Map RawSnapshotLocation SnapshotLocation -> Map RawPackageLocationImmutable PackageLocationImmutable -> RIO env (Snapshot, [CompletedSL], [CompletedPLI])

-- | As for loadAndCompleteSnapshot but allows toggling of the debug
--   output of the raw snapshot layer.
loadAndCompleteSnapshot' :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Bool -> SnapshotLocation -> Map RawSnapshotLocation SnapshotLocation -> Map RawPackageLocationImmutable PackageLocationImmutable -> RIO env (Snapshot, [CompletedSL], [CompletedPLI])

-- | Parse a Snapshot (all layers) from a RawSnapshotLocation
--   completing any incomplete package locations. Debug output will include
--   the raw snapshot layer.
loadAndCompleteSnapshotRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawSnapshotLocation -> Map RawSnapshotLocation SnapshotLocation -> Map RawPackageLocationImmutable PackageLocationImmutable -> RIO env (Snapshot, [CompletedSL], [CompletedPLI])

-- | As for loadAndCompleteSnapshotRaw but allows toggling of the
--   debug output of the raw snapshot layer.
loadAndCompleteSnapshotRaw' :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Bool -> RawSnapshotLocation -> Map RawSnapshotLocation SnapshotLocation -> Map RawPackageLocationImmutable PackageLocationImmutable -> RIO env (Snapshot, [CompletedSL], [CompletedPLI])

-- | A completed snapshot location, including the original raw and
--   completed information.
data CompletedSL
CompletedSL :: !RawSnapshotLocation -> !SnapshotLocation -> CompletedSL

-- | A completed package location, including the original raw and completed
--   information.
data CompletedPLI
CompletedPLI :: !RawPackageLocationImmutable -> !PackageLocationImmutable -> CompletedPLI

-- | Add more packages to a snapshot
--   
--   Note that any settings on a parent flag which is being replaced will
--   be ignored. For example, if package foo is in the parent and
--   has flag bar set, and foo also appears in new
--   packages, then bar will no longer be set.
--   
--   Returns any of the AddPackagesConfig values not used.
addPackagesToSnapshot :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Utf8Builder -> [RawPackageLocationImmutable] -> AddPackagesConfig -> Map PackageName RawSnapshotPackage -> RIO env (Map PackageName RawSnapshotPackage, AddPackagesConfig)

-- | Package settings to be passed to addPackagesToSnapshot.
data AddPackagesConfig
AddPackagesConfig :: !Set PackageName -> !Map PackageName (Map FlagName Bool) -> !Map PackageName Bool -> !Map PackageName [Text] -> AddPackagesConfig
[apcDrop] :: AddPackagesConfig -> !Set PackageName
[apcFlags] :: AddPackagesConfig -> !Map PackageName (Map FlagName Bool)
[apcHiddens] :: AddPackagesConfig -> !Map PackageName Bool
[apcGhcOptions] :: AddPackagesConfig -> !Map PackageName [Text]

-- | Complete package location, plus whether the package has a cabal file.
--   This is relevant to reproducibility, see
--   https://tech.fpcomplete.com/blog/storing-generated-cabal-files
data CompletePackageLocation
CompletePackageLocation :: !PackageLocationImmutable -> !Bool -> CompletePackageLocation
[cplComplete] :: CompletePackageLocation -> !PackageLocationImmutable
[cplHasCabalFile] :: CompletePackageLocation -> !Bool

-- | Fill in optional fields in a PackageLocationImmutable for more
--   reproducible builds.
completePackageLocation :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env CompletePackageLocation

-- | Add in hashes to make a SnapshotLocation reproducible.
completeSnapshotLocation :: (HasPantryConfig env, HasLogFunc env) => RawSnapshotLocation -> RIO env SnapshotLocation

-- | Warn if the package uses PCHpack.
warnMissingCabalFile :: HasLogFunc env => RawPackageLocationImmutable -> RIO env ()

-- | Parse a Text into a WantedCompiler value.
parseWantedCompiler :: Text -> Either PantryException WantedCompiler

-- | Parse the short representation of a SnapName.
parseSnapName :: MonadThrow m => Text -> m SnapName

-- | Parse a Text into an Unresolved
--   RawSnapshotLocation.
parseRawSnapshotLocation :: Text -> Unresolved RawSnapshotLocation

-- | Parse a PackageIdentifierRevision
parsePackageIdentifierRevision :: Text -> Either PantryException PackageIdentifierRevision

-- | Parse a hackage text.
parseHackageText :: Text -> Either PantryException (PackageIdentifier, BlobKey)

-- | This is almost a copy of Cabal's parser for package identifiers, the
--   main difference is in the fact that Stack requires version to be
--   present while Cabal uses "null version" as a default value
parsePackageIdentifier :: String -> Maybe PackageIdentifier

-- | Parse a package name from a Value.
parsePackageName :: String -> Maybe PackageName

-- | Parse a package name from a Value throwing on failure
parsePackageNameThrowing :: MonadThrow m => String -> m PackageName

-- | Parse a flag name from a Value.
parseFlagName :: String -> Maybe FlagName

-- | Parse a version from a Value.
parseVersion :: String -> Maybe Version

-- | Parse a package version from a Value throwing on failure
parseVersionThrowing :: MonadThrow m => String -> m Version

-- | Render a package identifier as a Value.
packageIdentifierString :: PackageIdentifier -> String

-- | Render a package name as a Value.
packageNameString :: PackageName -> String

-- | Render a flag name as a Value.
flagNameString :: FlagName -> String

-- | Render a version as a Value.
versionString :: Version -> String

-- | Render a module name as a Value.
moduleNameString :: ModuleName -> String

-- | Newtype wrapper for easier JSON integration with Cabal types.
newtype CabalString a
CabalString :: a -> CabalString a
[unCabalString] :: CabalString a -> a

-- | Wrap the keys in a Map with a CabalString to get a
--   ToJSON instance.
toCabalStringMap :: Map a v -> Map (CabalString a) v

-- | Unwrap the CabalString from the keys in a Map to use a
--   FromJSON instance.
unCabalStringMap :: Map (CabalString a) v -> Map a v

-- | Get the PackageIdentifier from a
--   GenericPackageDescription.
gpdPackageIdentifier :: GenericPackageDescription -> PackageIdentifier

-- | Get the PackageName from a GenericPackageDescription.
gpdPackageName :: GenericPackageDescription -> PackageName

-- | Get the Version from a GenericPackageDescription.
gpdVersion :: GenericPackageDescription -> Version

-- | Download all of the packages provided into the local cache without
--   performing any unpacking. Can be useful for build tools wanting to
--   prefetch or provide an offline mode.
fetchPackages :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env, Foldable f) => f PackageLocationImmutable -> RIO env ()

-- | Unpack a given RawPackageLocationImmutable into the given
--   directory. Does not generate any extra subdirectories.
unpackPackageLocationRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Path Abs Dir -> RawPackageLocationImmutable -> RIO env ()

-- | Unpack a given PackageLocationImmutable into the given
--   directory. Does not generate any extra subdirectories.
unpackPackageLocation :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Path Abs Dir -> PackageLocationImmutable -> RIO env ()

-- | Get the PackageName of the package at the given location.
getPackageLocationName :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env PackageName

-- | Get the PackageIdentifier of the package at the given location.
getRawPackageLocationIdent :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env PackageIdentifier

-- | Get the PackageIdentifier of the package at the given location.
packageLocationIdent :: PackageLocationImmutable -> PackageIdentifier

-- | Get version of the package at the given location.
packageLocationVersion :: PackageLocationImmutable -> Version

-- | Get the TreeKey of the package at the given location.
getRawPackageLocationTreeKey :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env TreeKey

-- | Get the TreeKey of the package at the given location.
getPackageLocationTreeKey :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => PackageLocationImmutable -> RIO env TreeKey

-- | Same as loadCabalFileRawImmutable, but takes a
--   RawPackageLocation. Never prints warnings, see
--   loadCabalFilePath for that.
loadCabalFileRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Maybe Text -> RawPackageLocation -> RIO env GenericPackageDescription

-- | Same as loadCabalFileImmutable, but takes a
--   PackageLocation. Never prints warnings, see
--   loadCabalFilePath for that.
loadCabalFile :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Maybe Text -> PackageLocation -> RIO env GenericPackageDescription

-- | Load the cabal file for the given RawPackageLocationImmutable.
--   
--   This function ignores all warnings.
--   
--   Note that, for now, this will not allow support for hpack files in
--   these package locations. Instead, all
--   PackageLocationImmutables will require a .cabal file. This
--   may be relaxed in the future.
loadCabalFileRawImmutable :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env GenericPackageDescription

-- | Load the cabal file for the given PackageLocationImmutable.
--   
--   This function ignores all warnings.
loadCabalFileImmutable :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => PackageLocationImmutable -> RIO env GenericPackageDescription

-- | Parse the Cabal file for the package inside the given directory.
--   Performs various sanity checks, such as the file name being correct
--   and having only a single Cabal file.
loadCabalFilePath :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Maybe Text -> Path Abs Dir -> RIO env (PrintWarnings -> IO GenericPackageDescription, PackageName, Path Abs File)

-- | Get the file name for the Cabal file in the given directory.
--   
--   If no Cabal file is present, or more than one is present, an exception
--   is thrown via throwM.
--   
--   If the directory contains a file named package.yaml, Hpack is used to
--   generate a Cabal file from it.
findOrGenerateCabalFile :: forall env. (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Maybe Text -> Path Abs Dir -> RIO env (PackageName, Path Abs File)

-- | Should we print warnings when loading a cabal file?
data PrintWarnings
YesPrintWarnings :: PrintWarnings
NoPrintWarnings :: PrintWarnings

-- | Download the most recent 01-index.tar file from Hackage and update the
--   database tables.
--   
--   This function will only perform an update once per PantryConfig
--   for user sanity. See the return value to find out if it happened.
updateHackageIndex :: (HasPantryConfig env, HasLogFunc env) => Maybe Utf8Builder -> RIO env DidUpdateOccur

-- | Did an update occur when running updateHackageIndex?
data DidUpdateOccur
UpdateOccurred :: DidUpdateOccur
NoUpdateOccurred :: DidUpdateOccur

-- | Require that the Hackage index is populated.
data RequireHackageIndex

-- | If there is nothing in the Hackage index, then perform an update
YesRequireHackageIndex :: RequireHackageIndex

-- | Do not perform an update
NoRequireHackageIndex :: RequireHackageIndex

-- | Where does pantry download its 01-index.tar file from Hackage?
hackageIndexTarballL :: HasPantryConfig env => SimpleGetter env (Path Abs File)

-- | Returns the versions of the package available on Hackage.
getHackagePackageVersions :: (HasPantryConfig env, HasLogFunc env) => RequireHackageIndex -> UsePreferredVersions -> PackageName -> RIO env (Map Version (Map Revision BlobKey))

-- | Returns the latest version of the given package available from
--   Hackage.
getLatestHackageVersion :: (HasPantryConfig env, HasLogFunc env) => RequireHackageIndex -> PackageName -> UsePreferredVersions -> RIO env (Maybe PackageIdentifierRevision)

-- | Returns location of the latest version of the given package available
--   from Hackage.
getLatestHackageLocation :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RequireHackageIndex -> PackageName -> UsePreferredVersions -> RIO env (Maybe PackageLocationImmutable)

-- | Returns the latest revision of the given package version available
--   from Hackage.
getLatestHackageRevision :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RequireHackageIndex -> PackageName -> Version -> RIO env (Maybe (Revision, BlobKey, TreeKey))

-- | Try to come up with typo corrections for given package identifier
--   using Hackage package names. This can provide more user-friendly
--   information in error messages.
getHackageTypoCorrections :: (HasPantryConfig env, HasLogFunc env) => PackageName -> RIO env [PackageName]

-- | Load the global hints from GitHub.
loadGlobalHints :: (HasTerm env, HasPantryConfig env) => WantedCompiler -> RIO env (Maybe (Map PackageName Version))

-- | Partition a map of global packages with its versions into a Set of
--   replaced packages and its dependencies and a map of remaining
--   (untouched) packages.
partitionReplacedDependencies :: Ord id => Map PackageName a -> (a -> PackageName) -> (a -> id) -> (a -> [id]) -> Set PackageName -> (Map PackageName [PackageName], Map PackageName a)

-- | An arbitrary hash for a snapshot, used for finding module names in a
--   snapshot. Mostly intended for Stack's usage.
newtype SnapshotCacheHash
SnapshotCacheHash :: SHA256 -> SnapshotCacheHash
[unSnapshotCacheHash] :: SnapshotCacheHash -> SHA256

-- | Use a snapshot cache, which caches which modules are in which packages
--   in a given snapshot. This is mostly intended for usage by Stack.
withSnapshotCache :: (HasPantryConfig env, HasLogFunc env) => SnapshotCacheHash -> RIO env (Map PackageName (Set ModuleName)) -> ((ModuleName -> RIO env [PackageName]) -> RIO env a) -> RIO env a
instance RIO.Prelude.Logger.HasLogFunc Pantry.PantryApp
instance Pantry.Types.HasPantryConfig Pantry.PantryApp
instance RIO.Process.HasProcessContext Pantry.PantryApp
instance RIO.PrettyPrint.StylesUpdate.HasStylesUpdate Pantry.PantryApp
instance RIO.PrettyPrint.HasTerm Pantry.PantryApp
instance GHC.Base.Semigroup (Pantry.SingleOrNot a)
