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


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

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 family Key record
data PackageName
data Version
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
data () => SafeFilePath
newtype () => ModuleNameP
ModuleNameP :: ModuleName -> ModuleNameP
[unModuleNameP] :: ModuleNameP -> ModuleName
newtype () => VersionP
VersionP :: Version -> VersionP
[unVersionP] :: VersionP -> Version
newtype () => PackageNameP
PackageNameP :: PackageName -> PackageNameP
[unPackageNameP] :: PackageNameP -> PackageName

-- | Configuration value used by the entire pantry package. Create one
--   using <tt>withPantryConfig</tt> or <tt>withPantryConfig'</tt>. See
--   also <tt>PantryApp</tt> 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 <tt>True</tt>.
[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 <a>GenericPackageDescription</a> until its
--   actually needed. Therefore, we keep the filepath and the
--   <a>PackageName</a> derived from that filepath. When the <tt>IO
--   GenericPackageDescription</tt> is run, it will ensure that the
--   <tt>PackageName</tt> 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.
--   <tt><a>https://casa.stackage.org</a></tt> 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

-- | 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 <a>getHackageTarball</a>
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
data family EntityField record :: Type -> Type
type HackageCabalId = Key HackageCabal
type ModuleNameId = Key ModuleName
type PackageNameId = Key PackageName
type TreeEntryId = Key TreeEntry
type TreeId = Key Tree
data family Unique record
type VersionId = Key Version

-- | The <a>TreeKey</a> containing this package.
--   
--   This is a hash of the binary representation of <a>packageTree</a>.
packageTreeKey :: Package -> TreeKey
unSafeFilePath :: SafeFilePath -> Text
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))

-- | Same as <a>updateHackageIndex</a>, 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
--   <tt>RawPackageLocationImmutable</tt>. 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)


-- | 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 <tt>withPantryConfig</tt> or <tt>withPantryConfig'</tt>. See
--   also <tt>PantryApp</tt> 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
--   <tt>defaultPackageIndexConfig</tt>.
--   
--   <i>NOTE</i> It's highly recommended to only use the official Hackage
--   server or a mirror. See
--   <a>https://github.com/commercialhaskell/stack/issues/4137</a>.
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 <tt>defaultHackageSecurityConfig</tt>.
--   
--   <i>NOTE</i> It's highly recommended to only use the official Hackage
--   server or a mirror. See
--   <a>https://github.com/commercialhaskell/stack/issues/4137</a>.
data () => HackageSecurityConfig
HackageSecurityConfig :: ![Text] -> !Int -> !Bool -> HackageSecurityConfig
[hscKeyIds] :: HackageSecurityConfig -> ![Text]
[hscKeyThreshold] :: HackageSecurityConfig -> !Int
[hscIgnoreExpiry] :: HackageSecurityConfig -> !Bool

-- | Default <a>PackageIndexConfig</a> value using the official Hackage
--   server.
defaultPackageIndexConfig :: PackageIndexConfig

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

-- | Default <a>HackageSecurityConfig</a> value using the official Hackage
--   server. The value of the <a>hscIgnoreExpiry</a> field is <a>True</a>.
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 <a>PantryConfig</a>.
class () => HasPantryConfig env

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

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

-- | Create a new <a>PantryConfig</a> with the given settings.
--   
--   For something easier to use in simple cases, see <a>runPantryApp</a>.
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 <a>withPantryConfig</a> or <a>withPantryConfig'</a>
--   directly. Uses basically sane settings, like sharing a pantry
--   directory with Stack.
--   
--   You can use <a>runPantryApp</a> to use this. A simple example is:
--   
--   <pre>
--   {-# 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 &gt;&gt;= liftIO . print
--    where
--     baseVersion = mkVersion [4, 19, 0, 0]
--     basePkgId = PackageIdentifierRevision "base" baseVersion CFILatest
--     baseLocation = RPLIHackage basePkgId Nothing
--   </pre>
data PantryApp

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

-- | Like <a>runPantryApp</a>, 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 <a>runPantryAppClean</a>.
runPantryAppWith :: MonadIO m => Int -> CasaRepoPrefix -> Int -> RIO PantryApp a -> m a

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

-- | Things that can go wrong in pantry. Note two things:
--   
--   <ul>
--   <li>Many other exception types may be thrown from underlying
--   libraries. Pantry does not attempt to wrap these underlying
--   exceptions.</li>
--   <li>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.</li>
--   </ul>
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 <a>DownloadInvalidSize</a> since <a>mismatchActual</a>
--   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
data () => PackageName
data () => Version
data () => FlagName
data () => PackageIdentifier
PackageIdentifier :: PackageName -> Version -> PackageIdentifier
[pkgName] :: PackageIdentifier -> PackageName
[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 <a>resolvePaths</a>.
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 <a>Tree</a>.
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
--   <a>https://www.fpcomplete.com/blog/2018/07/pantry-part-2-trees-keys</a>.
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 <a>TreeKey</a> containing this package.
--   
--   This is a hash of the binary representation of <a>packageTree</a>.
[packageTreeKey] :: Package -> !TreeKey

-- | The <a>Tree</a> 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
--   <tt>PackageIdentifier</tt> 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
--   <tt>Maybe</tt> on <tt>FileSize</tt> 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.
--   <tt>CFIHash</tt> 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 <a>CFIRevision</a>.
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 <a>fetchRepos</a>, except with <a>RawPackageMetadata</a> instead
--   of <a>PackageMetadata</a>.
fetchReposRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => [(Repo, RawPackageMetadata)] -> RIO env ()

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

-- | Convert <a>PackageLocation</a> 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 <a>BlobKey</a>
--   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 <a>BlobKey</a>
--   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 <a>slFlags</a>
[rspFlags] :: RawSnapshotPackage -> !Map FlagName Bool

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

-- | Same as <a>slGhcOptions</a>
[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 <a>slFlags</a>
[spFlags] :: SnapshotPackage -> !Map FlagName Bool

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

-- | Same as <a>slGhcOptions</a>
[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
--   <tt>SnapshotLocation</tt> which gives us more information (like
--   packages). Ultimately, we'll end up with a <tt>CompilerVersion</tt>.
[rslParent] :: RawSnapshotLayer -> !RawSnapshotLocation

-- | Override the compiler specified in <a>slParent</a>. Must be
--   <a>Nothing</a> if using <a>SLCompiler</a>.
[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
--   <a>Map</a> instead of just a <a>Set</a> 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 <a>slPublishTime</a>
[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
--   <tt>SnapshotLocation</tt> which gives us more information (like
--   packages). Ultimately, we'll end up with a <tt>CompilerVersion</tt>.
[slParent] :: SnapshotLayer -> !SnapshotLocation

-- | Override the compiler specified in <a>slParent</a>. Must be
--   <a>Nothing</a> if using <a>SLCompiler</a>.
[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
--   <a>Map</a> instead of just a <a>Set</a> 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
--   <a>snapshotLocation</a> of a <a>PantryConfig</a>.
--   
--   @ since 0.5.0.0
data () => SnapName
LTS :: !Int -> !Int -> SnapName

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

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

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

-- | Load a <a>Package</a> from a <a>RawPackageLocationImmutable</a>.
--   
--   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 <a>Package</a> from a <a>PackageLocationImmutable</a>.
loadPackage :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => PackageLocationImmutable -> RIO env Package

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

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

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

-- | Parse a <a>Snapshot</a> (all layers) from a <a>SnapshotLocation</a>
--   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 <a>loadAndCompleteSnapshot</a> 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 <a>Snapshot</a> (all layers) from a <a>RawSnapshotLocation</a>
--   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 <a>loadAndCompleteSnapshotRaw</a> 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 <tt>foo</tt> is in the parent and
--   has flag <tt>bar</tt> set, and <tt>foo</tt> also appears in new
--   packages, then <tt>bar</tt> will no longer be set.
--   
--   Returns any of the <a>AddPackagesConfig</a> 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 <a>addPackagesToSnapshot</a>.
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
--   <a>https://tech.fpcomplete.com/blog/storing-generated-cabal-files</a>
data CompletePackageLocation
CompletePackageLocation :: !PackageLocationImmutable -> !Bool -> CompletePackageLocation
[cplComplete] :: CompletePackageLocation -> !PackageLocationImmutable
[cplHasCabalFile] :: CompletePackageLocation -> !Bool

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

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

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

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

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

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

-- | Parse a <a>PackageIdentifierRevision</a>
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 <a>Value</a>.
parsePackageName :: String -> Maybe PackageName

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

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

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

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

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

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

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

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

-- | Render a module name as a <a>Value</a>.
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 <a>Map</a> with a <a>CabalString</a> to get a
--   <a>ToJSON</a> instance.
toCabalStringMap :: Map a v -> Map (CabalString a) v

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

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

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

-- | Get the <a>Version</a> from a <a>GenericPackageDescription</a>.
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 <a>RawPackageLocationImmutable</a> 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 <a>PackageLocationImmutable</a> 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 <a>PackageName</a> of the package at the given location.
getPackageLocationName :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env PackageName

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

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

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

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

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

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

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

-- | Load the cabal file for the given <a>RawPackageLocationImmutable</a>.
--   
--   This function ignores all warnings.
--   
--   Note that, for now, this will not allow support for hpack files in
--   these package locations. Instead, all
--   <tt>PackageLocationImmutable</tt>s 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 <a>PackageLocationImmutable</a>.
--   
--   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 <a>throwM</a>.
--   
--   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 <a>PantryConfig</a>
--   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 <a>updateHackageIndex</a>?
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)
