Commit f357f778 authored by bardur.arantsson's avatar bardur.arantsson
Browse files

Remove top-down resolver

Removing 'topdown' as a resolver choice means that 'choose' is also
obsolete and so it is removed too.
parent 5944c3e9
......@@ -65,8 +65,6 @@ module Distribution.Client.Dependency (
addDefaultSetupDependencies,
) where
import Distribution.Client.Dependency.TopDown
( topDownResolver )
import Distribution.Solver.Modular
( modularResolver, SolverConfig(..) )
import Distribution.Simple.PackageIndex (InstalledPackageIndex)
......@@ -104,7 +102,7 @@ import Distribution.System
import Distribution.Client.Utils
( duplicates, duplicatesBy, mergeBy, MergeResult(..) )
import Distribution.Simple.Utils
( comparing, warn, info )
( comparing )
import Distribution.Simple.Configure
( relaxPackageDeps )
import Distribution.Simple.Setup
......@@ -610,19 +608,12 @@ applySandboxInstallPolicy
-- ------------------------------------------------------------
chooseSolver :: Verbosity -> PreSolver -> CompilerInfo -> IO Solver
chooseSolver verbosity preSolver _cinfo =
chooseSolver _verbosity preSolver _cinfo =
case preSolver of
AlwaysTopDown -> do
warn verbosity "Topdown solver is deprecated"
return TopDown
AlwaysModular -> do
return Modular
Choose -> do
info verbosity "Choosing modular solver."
return Modular
runSolver :: Solver -> SolverConfig -> DependencyResolver UnresolvedPkgLoc
runSolver TopDown = const topDownResolver -- TODO: warn about unsupported options
runSolver Modular = modularResolver
-- | Run the dependency solver.
......
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Client.Dependency.TopDown.Types
-- Copyright : (c) Duncan Coutts 2008
-- License : BSD-like
--
-- Maintainer : cabal-devel@haskell.org
-- Stability : provisional
-- Portability : portable
--
-- Types for the top-down dependency resolver.
-----------------------------------------------------------------------------
{-# LANGUAGE CPP #-}
module Distribution.Client.Dependency.TopDown.Types where
import Distribution.Client.Types
( UnresolvedPkgLoc, UnresolvedSourcePackage )
import Distribution.InstalledPackageInfo
( InstalledPackageInfo )
import qualified Distribution.Solver.Types.ComponentDeps as CD
import Distribution.Solver.Types.OptionalStanza
import Distribution.Solver.Types.SolverPackage
import Distribution.Solver.Types.SolverId
import Distribution.Package
( PackageId, PackageIdentifier, Dependency
, Package(packageId) )
import Distribution.PackageDescription
( FlagAssignment )
-- ------------------------------------------------------------
-- * The various kinds of packages
-- ------------------------------------------------------------
type SelectablePackage
= InstalledOrSource InstalledPackageEx UnconfiguredPackage
type SelectedPackage
= InstalledOrSource InstalledPackageEx SemiConfiguredPackage
data InstalledOrSource installed source
= InstalledOnly installed
| SourceOnly source
| InstalledAndSource installed source
deriving Eq
data FinalSelectedPackage
= SelectedInstalled InstalledPackage
| SelectedSource (SolverPackage UnresolvedPkgLoc)
type TopologicalSortNumber = Int
-- | InstalledPackage caches its dependencies as source package IDs.
data InstalledPackage
= InstalledPackage
InstalledPackageInfo
[PackageId]
data InstalledPackageEx
= InstalledPackageEx
InstalledPackage
!TopologicalSortNumber
[PackageIdentifier] -- transitive closure of installed deps
data UnconfiguredPackage
= UnconfiguredPackage
UnresolvedSourcePackage
!TopologicalSortNumber
FlagAssignment
[OptionalStanza]
-- | This is a minor misnomer: it's more of a 'SemiSolverPackage'.
data SemiConfiguredPackage
= SemiConfiguredPackage
UnresolvedSourcePackage -- package info
FlagAssignment -- total flag assignment for the package
[OptionalStanza] -- enabled optional stanzas
[Dependency] -- dependencies we end up with when we apply
-- the flag assignment
instance Package InstalledPackage where
packageId (InstalledPackage pkg _) = packageId pkg
instance Package InstalledPackageEx where
packageId (InstalledPackageEx p _ _) = packageId p
instance Package UnconfiguredPackage where
packageId (UnconfiguredPackage p _ _ _) = packageId p
instance Package SemiConfiguredPackage where
packageId (SemiConfiguredPackage p _ _ _) = packageId p
instance (Package installed, Package source)
=> Package (InstalledOrSource installed source) where
packageId (InstalledOnly p ) = packageId p
packageId (SourceOnly p ) = packageId p
packageId (InstalledAndSource p _) = packageId p
instance Package FinalSelectedPackage where
packageId (SelectedInstalled pkg) = packageId pkg
packageId (SelectedSource pkg) = packageId pkg
-- | We can have constraints on selecting just installed or just source
-- packages.
--
-- In particular, installed packages can only depend on other installed
-- packages while packages that are not yet installed but which we plan to
-- install can depend on installed or other not-yet-installed packages.
--
data InstalledConstraint = InstalledConstraint
| SourceConstraint
deriving (Eq, Show)
-- | Package dependencies
--
-- The top-down solver uses its down type class for package dependencies,
-- because it wants to know these dependencies as PackageIds, rather than as
-- ComponentIds (so it cannot use PackageFixedDeps).
--
-- Ideally we would switch the top-down solver over to use ComponentIds
-- throughout; that means getting rid of this type class, and changing over the
-- package index type to use Cabal's rather than cabal-install's. That will
-- avoid the need for the local definitions of dependencyGraph and
-- reverseTopologicalOrder in the top-down solver.
--
-- Note that the top-down solver does not (and probably will never) make a
-- distinction between the various kinds of dependencies, so we return a flat
-- list here. If we get rid of this type class then any use of `sourceDeps`
-- should be replaced by @fold . depends@.
class Package a => PackageSourceDeps a where
sourceDeps :: a -> [PackageIdentifier]
instance PackageSourceDeps InstalledPackageEx where
sourceDeps (InstalledPackageEx _ _ deps) = deps
instance PackageSourceDeps (SolverPackage loc) where
sourceDeps pkg = map solverSrcId $ CD.nonSetupDeps (solverPkgDeps pkg)
instance PackageSourceDeps InstalledPackage where
sourceDeps (InstalledPackage _ deps) = deps
instance PackageSourceDeps FinalSelectedPackage where
sourceDeps (SelectedInstalled pkg) = sourceDeps pkg
sourceDeps (SelectedSource pkg) = sourceDeps pkg
......@@ -22,26 +22,22 @@ import Distribution.Compat.Binary (Binary(..))
-- | All the solvers that can be selected.
data PreSolver = AlwaysTopDown | AlwaysModular | Choose
data PreSolver = AlwaysModular
deriving (Eq, Ord, Show, Bounded, Enum, Generic)
-- | All the solvers that can be used.
data Solver = TopDown | Modular
data Solver = Modular
deriving (Eq, Ord, Show, Bounded, Enum, Generic)
instance Binary PreSolver
instance Binary Solver
instance Text PreSolver where
disp AlwaysTopDown = text "topdown"
disp AlwaysModular = text "modular"
disp Choose = text "choose"
parse = do
name <- Parse.munch1 isAlpha
case map toLower name of
"topdown" -> return AlwaysTopDown
"modular" -> return AlwaysModular
"choose" -> return Choose
_ -> Parse.pfail
-- | Global policy for all packages to say if we prefer package versions that
......
......@@ -1214,7 +1214,7 @@ defaultMaxBackjumps :: Int
defaultMaxBackjumps = 2000
defaultSolver :: PreSolver
defaultSolver = Choose
defaultSolver = AlwaysModular
allSolvers :: String
allSolvers = intercalate ", " (map display ([minBound .. maxBound] :: [PreSolver]))
......@@ -2086,7 +2086,7 @@ optionSolver :: (flags -> Flag PreSolver)
-> OptionField flags
optionSolver get set =
option [] ["solver"]
("Select dependency solver to use (default: " ++ display defaultSolver ++ "). Choices: " ++ allSolvers ++ ", where 'choose' chooses between 'topdown' and 'modular' based on compiler version.")
("Select dependency solver to use (default: " ++ display defaultSolver ++ "). Choices: " ++ allSolvers ++ ".")
get set
(reqArg "SOLVER" (readP_to_E (const $ "solver must be one of: " ++ allSolvers)
(toFlag `fmap` parse))
......
......@@ -198,9 +198,6 @@ executable cabal
Distribution.Client.Config
Distribution.Client.Configure
Distribution.Client.Dependency
Distribution.Client.Dependency.TopDown
Distribution.Client.Dependency.TopDown.Constraints
Distribution.Client.Dependency.TopDown.Types
Distribution.Client.Dependency.Types
Distribution.Client.DistDirLayout
Distribution.Client.Exec
......
......@@ -16,6 +16,7 @@
(#3429).
* The bootstrap script now works correctly when run from a Git
clone (#3439).
* Removed the top-down solver (#3598).
1.24.0.0 Ryan Thomas <ryan@ryant.org> March 2016
* If there are multiple remote repos, 'cabal update' now updates
......
......@@ -273,11 +273,9 @@ instance Arbitrary IndependentGoals where
shrink (IndependentGoals indep) = [IndependentGoals False | indep]
instance Arbitrary Solver where
arbitrary = frequency [ (1, return TopDown)
, (5, return Modular) ]
arbitrary = return Modular
shrink Modular = []
shrink TopDown = [Modular]
instance Arbitrary Component where
arbitrary = oneof [ return ComponentLib
......
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