Commit 68dbc51b authored by bardur.arantsson's avatar bardur.arantsson

Introduce UnresolvedSourcePackage alias

The alias is a shorthand for 'SourcePackage UnresolvedPkgLoc' which is
used all over the place.
parent e786c34f
......@@ -73,7 +73,7 @@ import Distribution.Client.PkgConfigDb (PkgConfigDb)
import Distribution.Client.Types
( SourcePackageDb(SourcePackageDb), SourcePackage(..)
, ConfiguredPackage(..), ConfiguredId(..)
, UnresolvedPkgLoc
, UnresolvedPkgLoc, UnresolvedSourcePackage
, OptionalStanza(..), enableStanzas )
import Distribution.Client.Dependency.Types
( PreSolver(..), Solver(..), DependencyResolver, ResolverPackage(..)
......@@ -146,7 +146,7 @@ data DepResolverParams = DepResolverParams {
depResolverPreferences :: [PackagePreference],
depResolverPreferenceDefault :: PackagesPreferenceDefault,
depResolverInstalledPkgIndex :: InstalledPackageIndex,
depResolverSourcePkgIndex :: PackageIndex.PackageIndex (SourcePackage UnresolvedPkgLoc),
depResolverSourcePkgIndex :: PackageIndex.PackageIndex UnresolvedSourcePackage,
depResolverReorderGoals :: Bool,
depResolverIndependentGoals :: Bool,
depResolverAvoidReinstalls :: Bool,
......@@ -208,7 +208,7 @@ showPackagePreference (PackageStanzasPreference pn st) =
display pn ++ " " ++ show st
basicDepResolverParams :: InstalledPackageIndex
-> PackageIndex.PackageIndex (SourcePackage UnresolvedPkgLoc)
-> PackageIndex.PackageIndex UnresolvedSourcePackage
-> DepResolverParams
basicDepResolverParams installedPkgIndex sourcePkgIndex =
DepResolverParams {
......@@ -313,7 +313,7 @@ dontUpgradeNonUpgradeablePackages params =
. InstalledPackageIndex.lookupPackageName
(depResolverInstalledPkgIndex params)
addSourcePackages :: [SourcePackage UnresolvedPkgLoc]
addSourcePackages :: [UnresolvedSourcePackage]
-> DepResolverParams -> DepResolverParams
addSourcePackages pkgs params =
params {
......@@ -382,7 +382,7 @@ removeUpperBounds allowNewer params =
where
sourcePkgIndex' = fmap relaxDeps $ depResolverSourcePkgIndex params
relaxDeps :: SourcePackage UnresolvedPkgLoc -> SourcePackage UnresolvedPkgLoc
relaxDeps :: UnresolvedSourcePackage -> UnresolvedSourcePackage
relaxDeps srcPkg = srcPkg {
packageDescription = relaxPackageDeps allowNewer
(packageDescription srcPkg)
......@@ -394,7 +394,7 @@ removeUpperBounds allowNewer params =
-- 'addSourcePackages'. Otherwise, the packages inserted by
-- 'addSourcePackages' won't have upper bounds in dependencies relaxed.
--
addDefaultSetupDependencies :: (SourcePackage UnresolvedPkgLoc -> [Dependency])
addDefaultSetupDependencies :: (UnresolvedSourcePackage -> [Dependency])
-> DepResolverParams -> DepResolverParams
addDefaultSetupDependencies defaultSetupDeps params =
params {
......@@ -402,7 +402,7 @@ addDefaultSetupDependencies defaultSetupDeps params =
fmap applyDefaultSetupDeps (depResolverSourcePkgIndex params)
}
where
applyDefaultSetupDeps :: SourcePackage UnresolvedPkgLoc -> SourcePackage UnresolvedPkgLoc
applyDefaultSetupDeps :: UnresolvedSourcePackage -> UnresolvedSourcePackage
applyDefaultSetupDeps srcpkg =
srcpkg {
packageDescription = gpkgdesc {
......@@ -432,7 +432,7 @@ reinstallTargets params =
standardInstallPolicy :: InstalledPackageIndex
-> SourcePackageDb
-> [PackageSpecifier (SourcePackage UnresolvedPkgLoc)]
-> [PackageSpecifier UnresolvedSourcePackage]
-> DepResolverParams
standardInstallPolicy
installedPkgIndex (SourcePackageDb sourcePkgIndex sourcePkgPrefs)
......@@ -788,14 +788,14 @@ configuredPackageProblems platform cinfo
-- It simply means preferences for installed packages will be ignored.
--
resolveWithoutDependencies :: DepResolverParams
-> Either [ResolveNoDepsError] [SourcePackage UnresolvedPkgLoc]
-> Either [ResolveNoDepsError] [UnresolvedSourcePackage]
resolveWithoutDependencies (DepResolverParams targets constraints
prefs defpref installedPkgIndex sourcePkgIndex
_reorderGoals _indGoals _avoidReinstalls
_shadowing _strFlags _maxBjumps) =
collectEithers (map selectPackage targets)
where
selectPackage :: PackageName -> Either ResolveNoDepsError (SourcePackage UnresolvedPkgLoc)
selectPackage :: PackageName -> Either ResolveNoDepsError UnresolvedSourcePackage
selectPackage pkgname
| null choices = Left $! ResolveUnsatisfiable pkgname requiredVersions
| otherwise = Right $! maximumBy bestByPrefs choices
......
......@@ -21,7 +21,7 @@ import Distribution.Client.Dependency.TopDown.Constraints
( Satisfiable(..) )
import Distribution.Client.Types
( SourcePackage(..), ConfiguredPackage(..)
, UnresolvedPkgLoc
, UnresolvedPkgLoc, UnresolvedSourcePackage
, enableStanzas, ConfiguredId(..), fakeUnitId )
import Distribution.Client.Dependency.Types
( DependencyResolver, ResolverPackage(..)
......@@ -269,7 +269,7 @@ topDownResolver platform cinfo installedPkgIndex sourcePkgIndex _pkgConfigDB
--
topDownResolver' :: Platform -> CompilerInfo
-> PackageIndex InstalledPackage
-> PackageIndex (SourcePackage UnresolvedPkgLoc)
-> PackageIndex UnresolvedSourcePackage
-> (PackageName -> PackagePreferences)
-> [PackageConstraint]
-> [PackageName]
......@@ -447,7 +447,7 @@ annotateInstalledPackages dfsNumber installed = PackageIndex.fromList
--
annotateSourcePackages :: [PackageConstraint]
-> (PackageName -> TopologicalSortNumber)
-> PackageIndex (SourcePackage UnresolvedPkgLoc)
-> PackageIndex UnresolvedSourcePackage
-> PackageIndex UnconfiguredPackage
annotateSourcePackages constraints dfsNumber sourcePkgIndex =
PackageIndex.fromList
......@@ -484,7 +484,7 @@ annotateSourcePackages constraints dfsNumber sourcePkgIndex =
-- heuristic.
--
topologicalSortNumbering :: PackageIndex InstalledPackage
-> PackageIndex (SourcePackage UnresolvedPkgLoc)
-> PackageIndex UnresolvedSourcePackage
-> (PackageName -> TopologicalSortNumber)
topologicalSortNumbering installedPkgIndex sourcePkgIndex =
\pkgname -> let Just vertex = toVertex pkgname
......@@ -511,17 +511,17 @@ topologicalSortNumbering installedPkgIndex sourcePkgIndex =
-- and looking at the names of all possible dependencies.
--
selectNeededSubset :: PackageIndex InstalledPackage
-> PackageIndex (SourcePackage UnresolvedPkgLoc)
-> PackageIndex UnresolvedSourcePackage
-> Set PackageName
-> (PackageIndex InstalledPackage
,PackageIndex (SourcePackage UnresolvedPkgLoc))
,PackageIndex UnresolvedSourcePackage)
selectNeededSubset installedPkgIndex sourcePkgIndex = select mempty mempty
where
select :: PackageIndex InstalledPackage
-> PackageIndex (SourcePackage UnresolvedPkgLoc)
-> PackageIndex UnresolvedSourcePackage
-> Set PackageName
-> (PackageIndex InstalledPackage
,PackageIndex (SourcePackage UnresolvedPkgLoc))
,PackageIndex UnresolvedSourcePackage)
select installedPkgIndex' sourcePkgIndex' remaining
| Set.null remaining = (installedPkgIndex', sourcePkgIndex')
| otherwise = select installedPkgIndex'' sourcePkgIndex'' remaining''
......
......@@ -14,8 +14,8 @@
module Distribution.Client.Dependency.TopDown.Types where
import Distribution.Client.Types
( SourcePackage(..), ConfiguredPackage(..)
, UnresolvedPkgLoc
( ConfiguredPackage(..)
, UnresolvedPkgLoc, UnresolvedSourcePackage
, OptionalStanza, ConfiguredId(..) )
import Distribution.InstalledPackageInfo
( InstalledPackageInfo )
......@@ -63,14 +63,14 @@ data InstalledPackageEx
data UnconfiguredPackage
= UnconfiguredPackage
(SourcePackage UnresolvedPkgLoc)
UnresolvedSourcePackage
!TopologicalSortNumber
FlagAssignment
[OptionalStanza]
data SemiConfiguredPackage
= SemiConfiguredPackage
(SourcePackage UnresolvedPkgLoc) -- package info
UnresolvedSourcePackage -- package info
FlagAssignment -- total flag assignment for the package
[OptionalStanza] -- enabled optional stanzas
[Dependency] -- dependencies we end up with when we apply
......
......@@ -120,8 +120,8 @@ planPackages :: Verbosity
-> InstalledPackageIndex
-> SourcePackageDb
-> PkgConfigDb
-> [PackageSpecifier (SourcePackage UnresolvedPkgLoc)]
-> IO [SourcePackage UnresolvedPkgLoc]
-> [PackageSpecifier UnresolvedSourcePackage]
-> IO [UnresolvedSourcePackage]
planPackages verbosity comp platform fetchFlags
installedPkgIndex sourcePkgDb pkgConfigDb pkgSpecifiers
......
......@@ -131,7 +131,7 @@ planPackages :: Verbosity
-> InstalledPackageIndex
-> SourcePackageDb
-> PkgConfigDb
-> [PackageSpecifier (SourcePackage UnresolvedPkgLoc)]
-> [PackageSpecifier UnresolvedSourcePackage]
-> IO [PlanPackage]
planPackages verbosity comp platform mSandboxPkgInfo freezeFlags
installedPkgIndex sourcePkgDb pkgConfigDb pkgSpecifiers = do
......@@ -196,7 +196,7 @@ planPackages verbosity comp platform mSandboxPkgInfo freezeFlags
-- freezing. This is useful for removing previously installed packages
-- which are no longer required from the install plan.
pruneInstallPlan :: InstallPlan
-> [PackageSpecifier (SourcePackage UnresolvedPkgLoc)]
-> [PackageSpecifier UnresolvedSourcePackage]
-> [PlanPackage]
pruneInstallPlan installPlan pkgSpecifiers =
removeSelf pkgIds $
......
......@@ -113,13 +113,13 @@ get verbosity repoCtxt globalFlags getFlags userTargets = do
prefix = fromFlagOrDefault "" (getDestDir getFlags)
fork :: [SourcePackage UnresolvedPkgLoc] -> IO ()
fork :: [UnresolvedSourcePackage] -> IO ()
fork pkgs = do
let kind = fromFlag . getSourceRepository $ getFlags
branchers <- findUsableBranchers
mapM_ (forkPackage verbosity branchers prefix kind) pkgs
unpack :: [SourcePackage UnresolvedPkgLoc] -> IO ()
unpack :: [UnresolvedSourcePackage] -> IO ()
unpack pkgs = do
forM_ pkgs $ \pkg -> do
location <- fetchPackage verbosity repoCtxt (packageSource pkg)
......
......@@ -154,7 +154,7 @@ readCacheStrict verbosity index mkPkg = do
-- This is a higher level wrapper used internally in cabal-install.
--
readRepoIndex :: Verbosity -> RepoContext -> Repo
-> IO (PackageIndex (SourcePackage UnresolvedPkgLoc), [Dependency])
-> IO (PackageIndex UnresolvedSourcePackage, [Dependency])
readRepoIndex verbosity repoCtxt repo =
handleNotFound $ do
warnIfIndexIsOld =<< getIndexFileAge repo
......
......@@ -237,7 +237,7 @@ install verbosity packageDBs repos comp platform conf useSandbox mSandboxPkgInfo
-- | Common context for makeInstallPlan and processInstallPlan.
type InstallContext = ( InstalledPackageIndex, SourcePackageDb
, PkgConfigDb
, [UserTarget], [PackageSpecifier (SourcePackage UnresolvedPkgLoc)]
, [UserTarget], [PackageSpecifier UnresolvedSourcePackage]
, HttpTransport )
-- TODO: Make InstallArgs a proper data type with documented fields or just get
......@@ -342,7 +342,7 @@ planPackages :: Compiler
-> InstalledPackageIndex
-> SourcePackageDb
-> PkgConfigDb
-> [PackageSpecifier (SourcePackage UnresolvedPkgLoc)]
-> [PackageSpecifier UnresolvedSourcePackage]
-> Progress String String InstallPlan
planPackages comp platform mSandboxPkgInfo solver
configFlags configExFlags installFlags
......@@ -467,7 +467,7 @@ checkPrintPlan :: Verbosity
-> InstallPlan
-> SourcePackageDb
-> InstallFlags
-> [PackageSpecifier (SourcePackage UnresolvedPkgLoc)]
-> [PackageSpecifier UnresolvedSourcePackage]
-> IO ()
checkPrintPlan verbosity installed installPlan sourcePkgDb
installFlags pkgSpecifiers = do
......
......@@ -43,7 +43,8 @@ import Distribution.Text
( Text(disp), display )
import Distribution.Client.Types
( SourcePackage(..), SourcePackageDb(..), UnresolvedPkgLoc )
( SourcePackage(..), SourcePackageDb(..)
, UnresolvedSourcePackage )
import Distribution.Client.Dependency.Types
( PackageConstraint(..) )
import Distribution.Client.Targets
......@@ -90,7 +91,7 @@ getPkgList verbosity packageDBs repoCtxt comp conf listFlags pats = do
(Map.lookup name (packagePreferences sourcePkgDb))
pkgsInfo ::
[(PackageName, [Installed.InstalledPackageInfo], [SourcePackage UnresolvedPkgLoc])]
[(PackageName, [Installed.InstalledPackageInfo], [UnresolvedSourcePackage])]
pkgsInfo
-- gather info for all packages
| null pats = mergePackages
......@@ -101,7 +102,7 @@ getPkgList verbosity packageDBs repoCtxt comp conf listFlags pats = do
| otherwise = pkgsInfoMatching
pkgsInfoMatching ::
[(PackageName, [Installed.InstalledPackageInfo], [SourcePackage UnresolvedPkgLoc])]
[(PackageName, [Installed.InstalledPackageInfo], [UnresolvedSourcePackage])]
pkgsInfoMatching =
let matchingInstalled = matchingPackages
InstalledPackageIndex.searchByNameSubstring
......@@ -206,8 +207,8 @@ info verbosity packageDBs repoCtxt comp conf
where
gatherPkgInfo :: (PackageName -> VersionRange) ->
InstalledPackageIndex ->
PackageIndex.PackageIndex (SourcePackage UnresolvedPkgLoc) ->
PackageSpecifier (SourcePackage UnresolvedPkgLoc) ->
PackageIndex.PackageIndex UnresolvedSourcePackage ->
PackageSpecifier UnresolvedSourcePackage ->
Either String PackageDisplayInfo
gatherPkgInfo prefs installedPkgIndex sourcePkgIndex
(NamedPackage name constraints)
......@@ -251,8 +252,8 @@ sourcePkgsInfo ::
(PackageName -> VersionRange)
-> PackageName
-> InstalledPackageIndex
-> PackageIndex.PackageIndex (SourcePackage UnresolvedPkgLoc)
-> (VersionRange, [Installed.InstalledPackageInfo], [SourcePackage UnresolvedPkgLoc])
-> PackageIndex.PackageIndex UnresolvedSourcePackage
-> (VersionRange, [Installed.InstalledPackageInfo], [UnresolvedSourcePackage])
sourcePkgsInfo prefs name installedPkgIndex sourcePkgIndex =
(pref, installedPkgs, sourcePkgs)
where
......@@ -268,7 +269,7 @@ sourcePkgsInfo prefs name installedPkgIndex sourcePkgIndex =
data PackageDisplayInfo = PackageDisplayInfo {
pkgName :: PackageName,
selectedVersion :: Maybe Version,
selectedSourcePkg :: Maybe (SourcePackage UnresolvedPkgLoc),
selectedSourcePkg :: Maybe UnresolvedSourcePackage,
installedVersions :: [Version],
sourceVersions :: [Version],
preferredVersions :: VersionRange,
......@@ -417,8 +418,8 @@ reflowLines = vcat . map text . lines
--
mergePackageInfo :: VersionRange
-> [Installed.InstalledPackageInfo]
-> [SourcePackage UnresolvedPkgLoc]
-> Maybe (SourcePackage UnresolvedPkgLoc)
-> [UnresolvedSourcePackage]
-> Maybe UnresolvedSourcePackage
-> Bool
-> PackageDisplayInfo
mergePackageInfo versionPref installedPkgs sourcePkgs selectedPkg showVer =
......@@ -520,10 +521,10 @@ latestWithPref pref pkgs = Just (maximumBy (comparing prefThenVersion) pkgs)
-- both be empty.
--
mergePackages :: [Installed.InstalledPackageInfo]
-> [SourcePackage UnresolvedPkgLoc]
-> [UnresolvedSourcePackage]
-> [( PackageName
, [Installed.InstalledPackageInfo]
, [SourcePackage UnresolvedPkgLoc] )]
, [UnresolvedSourcePackage] )]
mergePackages installedPkgs sourcePkgs =
map collect
$ mergeBy (\i a -> fst i `compare` fst a)
......
......@@ -14,7 +14,7 @@ module Distribution.Client.Sandbox.Types (
) where
import qualified Distribution.Simple.PackageIndex as InstalledPackageIndex
import Distribution.Client.Types (SourcePackage, UnresolvedPkgLoc)
import Distribution.Client.Types (UnresolvedSourcePackage)
import Distribution.Compat.Semigroup (Semigroup((<>)))
#if !MIN_VERSION_base(4,8,0)
......@@ -49,11 +49,11 @@ whenUsingSandbox (UseSandbox sandboxDir) act = act sandboxDir
-- | Data about the packages installed in the sandbox that is passed from
-- 'reinstallAddSourceDeps' to the solver.
data SandboxPackageInfo = SandboxPackageInfo {
modifiedAddSourceDependencies :: ![SourcePackage UnresolvedPkgLoc],
modifiedAddSourceDependencies :: ![UnresolvedSourcePackage],
-- ^ Modified add-source deps that we want to reinstall. These are guaranteed
-- to be already installed in the sandbox.
otherAddSourceDependencies :: ![SourcePackage UnresolvedPkgLoc],
otherAddSourceDependencies :: ![UnresolvedSourcePackage],
-- ^ Remaining add-source deps. Some of these may be not installed in the
-- sandbox.
......
......@@ -54,7 +54,7 @@ import Distribution.Package
, Dependency(Dependency) )
import Distribution.Client.Types
( SourcePackage(..), PackageLocation(..), OptionalStanza(..)
, ResolvedPkgLoc, UnresolvedPkgLoc )
, ResolvedPkgLoc, UnresolvedSourcePackage )
import Distribution.Client.Dependency.Types
( PackageConstraint(..), ConstraintSource(..)
, LabeledPackageConstraint(..) )
......@@ -373,7 +373,7 @@ resolveUserTargets :: Package pkg
-> FilePath
-> PackageIndex pkg
-> [UserTarget]
-> IO [PackageSpecifier (SourcePackage UnresolvedPkgLoc)]
-> IO [PackageSpecifier UnresolvedSourcePackage]
resolveUserTargets verbosity repoCtxt worldFile available userTargets = do
-- given the user targets, get a list of fully or partially resolved
......@@ -483,7 +483,7 @@ fetchPackageTarget verbosity repoCtxt target = case target of
--
readPackageTarget :: Verbosity
-> PackageTarget ResolvedPkgLoc
-> IO (PackageTarget (SourcePackage UnresolvedPkgLoc))
-> IO (PackageTarget UnresolvedSourcePackage)
readPackageTarget verbosity target = case target of
PackageTargetNamed pkgname constraints userTarget ->
......
......@@ -53,7 +53,7 @@ newtype Password = Password { unPassword :: String }
-- | This is the information we get from a @00-index.tar.gz@ hackage index.
--
data SourcePackageDb = SourcePackageDb {
packageIndex :: PackageIndex (SourcePackage UnresolvedPkgLoc),
packageIndex :: PackageIndex UnresolvedSourcePackage,
packagePreferences :: Map PackageName VersionRange
}
deriving (Eq, Generic)
......@@ -176,6 +176,9 @@ data SourcePackage loc = SourcePackage {
instance (Binary loc) => Binary (SourcePackage loc)
-- | Convenience alias for 'SourcePackage UnresolvedPkgLoc'.
type UnresolvedSourcePackage = SourcePackage UnresolvedPkgLoc
-- | We sometimes need to override the .cabal file in the tarball with
-- the newer one from the package index.
type PackageDescriptionOverride = Maybe ByteString
......
......@@ -156,7 +156,7 @@ type DependencyTree a = C.CondTree C.ConfVar [C.Dependency] a
exDbPkgs :: ExampleDb -> [ExamplePkgName]
exDbPkgs = map (either exInstName exAvName)
exAvSrcPkg :: ExampleAvailable -> SourcePackage UnresolvedPkgLoc
exAvSrcPkg :: ExampleAvailable -> UnresolvedSourcePackage
exAvSrcPkg ex =
let (libraryDeps, testSuites, exts, mlang, pcpkgs) = splitTopLevel (CD.libraryDeps (exAvDeps ex))
in SourcePackage {
......@@ -339,7 +339,7 @@ exInstPkgId ex = C.PackageIdentifier {
, pkgVersion = Version [exInstVersion ex, 0, 0] []
}
exAvIdx :: [ExampleAvailable] -> CI.PackageIndex.PackageIndex (SourcePackage UnresolvedPkgLoc)
exAvIdx :: [ExampleAvailable] -> CI.PackageIndex.PackageIndex UnresolvedSourcePackage
exAvIdx = CI.PackageIndex.fromList . map exAvSrcPkg
exInstIdx :: [ExampleInstalled] -> C.PackageIndex.InstalledPackageIndex
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment