Skip to content

Commit

Permalink
Remove a couple uses of the InstalledPackage wrapper type
Browse files Browse the repository at this point in the history
Removed from the InstallPlan and solver interface.
The InstalledPackage is really just there for the benefit of the old
TopDown solver which needs to know source deps.
  • Loading branch information
dcoutts authored and 23Skidoo committed Jul 30, 2015
1 parent 5b90298 commit 3f3410b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Expand Up @@ -12,16 +12,14 @@ import Distribution.Client.Dependency.Modular.Configured
import Distribution.Client.Dependency.Modular.Package

import Distribution.Client.ComponentDeps (ComponentDeps)
import qualified Distribution.Client.ComponentDeps as CD


convCP :: SI.InstalledPackageIndex -> CI.PackageIndex SourcePackage ->
CP QPN -> ResolverPackage
convCP iidx sidx (CP qpi fa es ds) =
case convPI qpi of
Left pi -> PreExisting $ InstalledPackage
Left pi -> PreExisting
(fromJust $ SI.lookupInstalledPackageId iidx pi)
(map confSrcId $ CD.nonSetupDeps ds')
Right pi -> Configured $ ConfiguredPackage
(fromJust $ CI.lookupPackageId sidx pi)
fa
Expand Down
3 changes: 2 additions & 1 deletion cabal-install/Distribution/Client/Dependency/TopDown.hs
Expand Up @@ -292,7 +292,8 @@ topDownResolver' platform cinfo installedPkgIndex sourcePkgIndex
$ finaliseSelectedPackages preferences selected' constraints'

toResolverPackage :: FinalSelectedPackage -> ResolverPackage
toResolverPackage (SelectedInstalled pkg) = PreExisting pkg
toResolverPackage (SelectedInstalled (InstalledPackage pkg _))
= PreExisting pkg
toResolverPackage (SelectedSource pkg) = Configured pkg

addTopLevelTargets :: [PackageName]
Expand Down
7 changes: 4 additions & 3 deletions cabal-install/Distribution/Client/Dependency/Types.hs
Expand Up @@ -46,8 +46,7 @@ import Data.Monoid
#endif

import Distribution.Client.Types
( OptionalStanza(..), SourcePackage(..), ConfiguredPackage
, InstalledPackage )
( OptionalStanza(..), SourcePackage(..), ConfiguredPackage )

import Distribution.Compat.ReadP
( (<++) )
Expand All @@ -56,6 +55,8 @@ import qualified Distribution.Compat.ReadP as Parse
( pfail, munch1 )
import Distribution.PackageDescription
( FlagAssignment, FlagName(..) )
import Distribution.InstalledPackageInfo
( InstalledPackageInfo )
import qualified Distribution.Client.PackageIndex as PackageIndex
( PackageIndex )
import Distribution.Simple.PackageIndex ( InstalledPackageIndex )
Expand Down Expand Up @@ -128,7 +129,7 @@ type DependencyResolver = Platform
--
-- This is like the 'InstallPlan.PlanPackage' but with fewer cases.
--
data ResolverPackage = PreExisting InstalledPackage
data ResolverPackage = PreExisting InstalledPackageInfo
| Configured ConfiguredPackage

-- | Per-package constraints. Package constraints must be respected by the
Expand Down
10 changes: 6 additions & 4 deletions cabal-install/Distribution/Client/InstallPlan.hs
Expand Up @@ -49,9 +49,9 @@ module Distribution.Client.InstallPlan (
import Distribution.Client.Types
( ConfiguredPackage(..)
, ReadyPackage(..), readyPackageToConfiguredPackage
, InstalledPackage, BuildFailure, BuildSuccess(..)
, InstalledPackage(..), fakeInstalledPackageId
, BuildFailure, BuildSuccess(..)
, PackageFixedDeps(..)
, fakeInstalledPackageId
)
import Distribution.Package
( PackageIdentifier(..), PackageName(..), Package(..)
Expand All @@ -74,6 +74,8 @@ import Distribution.Compiler
( CompilerInfo(..) )
import Distribution.Simple.Utils
( intercalate )
import Distribution.InstalledPackageInfo
( InstalledPackageInfo )
import qualified Distribution.InstalledPackageInfo as Installed

import Data.Maybe
Expand Down Expand Up @@ -141,7 +143,7 @@ type PlanIndex = PackageIndex PlanPackage
-- 'PackageInstalled' instance it would be too easy to get this wrong (and,
-- for instance, call graph traversal functions from Cabal rather than from
-- cabal-install). Instead, see 'PackageFixedDeps'.
data PlanPackage = PreExisting InstalledPackage
data PlanPackage = PreExisting InstalledPackageInfo
| Configured ConfiguredPackage
| Processing ReadyPackage
| Installed ReadyPackage BuildSuccess
Expand Down Expand Up @@ -294,7 +296,7 @@ ready plan = assert check readyPackages
Just (Configured _) -> Nothing
Just (Processing _) -> Nothing
Just (Failed _ _) -> internalError depOnFailed
Just (PreExisting (InstalledPackage instPkg _)) -> Just instPkg
Just (PreExisting instPkg) -> Just instPkg
Just (Installed _ (BuildOk _ _ (Just instPkg))) -> Just instPkg
Just (Installed _ (BuildOk _ _ Nothing)) -> internalError depOnNonLib
Nothing -> internalError incomplete
Expand Down

0 comments on commit 3f3410b

Please sign in to comment.