Commit b4d86b68 authored by kristenk's avatar kristenk

Use newtypes for Bool solver options

parent edb7a742
......@@ -78,7 +78,8 @@ import Distribution.Client.Types
, OptionalStanza(..), enableStanzas )
import Distribution.Client.Dependency.Types
( PreSolver(..), Solver(..), DependencyResolver, ResolverPackage(..)
, EnableBackjumping(..)
, ReorderGoals(..), IndependentGoals(..), AvoidReinstalls(..)
, ShadowPkgs(..), StrongFlags(..), EnableBackjumping(..)
, PackageConstraint(..), showPackageConstraint
, LabeledPackageConstraint(..), unlabelPackageConstraint
, ConstraintSource(..), showConstraintSource
......@@ -147,11 +148,11 @@ data DepResolverParams = DepResolverParams {
depResolverPreferenceDefault :: PackagesPreferenceDefault,
depResolverInstalledPkgIndex :: InstalledPackageIndex,
depResolverSourcePkgIndex :: PackageIndex.PackageIndex UnresolvedSourcePackage,
depResolverReorderGoals :: Bool,
depResolverIndependentGoals :: Bool,
depResolverAvoidReinstalls :: Bool,
depResolverShadowPkgs :: Bool,
depResolverStrongFlags :: Bool,
depResolverReorderGoals :: ReorderGoals,
depResolverIndependentGoals :: IndependentGoals,
depResolverAvoidReinstalls :: AvoidReinstalls,
depResolverShadowPkgs :: ShadowPkgs,
depResolverStrongFlags :: StrongFlags,
depResolverMaxBackjumps :: Maybe Int,
depResolverEnableBackjumping :: EnableBackjumping
}
......@@ -219,11 +220,11 @@ basicDepResolverParams installedPkgIndex sourcePkgIndex =
depResolverPreferenceDefault = PreferLatestForSelected,
depResolverInstalledPkgIndex = installedPkgIndex,
depResolverSourcePkgIndex = sourcePkgIndex,
depResolverReorderGoals = False,
depResolverIndependentGoals = False,
depResolverAvoidReinstalls = False,
depResolverShadowPkgs = False,
depResolverStrongFlags = False,
depResolverReorderGoals = ReorderGoals False,
depResolverIndependentGoals = IndependentGoals False,
depResolverAvoidReinstalls = AvoidReinstalls False,
depResolverShadowPkgs = ShadowPkgs False,
depResolverStrongFlags = StrongFlags False,
depResolverMaxBackjumps = Nothing,
depResolverEnableBackjumping = EnableBackjumping True
}
......@@ -258,34 +259,34 @@ setPreferenceDefault preferenceDefault params =
depResolverPreferenceDefault = preferenceDefault
}
setReorderGoals :: Bool -> DepResolverParams -> DepResolverParams
setReorderGoals b params =
setReorderGoals :: ReorderGoals -> DepResolverParams -> DepResolverParams
setReorderGoals reorder params =
params {
depResolverReorderGoals = b
depResolverReorderGoals = reorder
}
setIndependentGoals :: Bool -> DepResolverParams -> DepResolverParams
setIndependentGoals b params =
setIndependentGoals :: IndependentGoals -> DepResolverParams -> DepResolverParams
setIndependentGoals indep params =
params {
depResolverIndependentGoals = b
depResolverIndependentGoals = indep
}
setAvoidReinstalls :: Bool -> DepResolverParams -> DepResolverParams
setAvoidReinstalls b params =
setAvoidReinstalls :: AvoidReinstalls -> DepResolverParams -> DepResolverParams
setAvoidReinstalls avoid params =
params {
depResolverAvoidReinstalls = b
depResolverAvoidReinstalls = avoid
}
setShadowPkgs :: Bool -> DepResolverParams -> DepResolverParams
setShadowPkgs b params =
setShadowPkgs :: ShadowPkgs -> DepResolverParams -> DepResolverParams
setShadowPkgs shadow params =
params {
depResolverShadowPkgs = b
depResolverShadowPkgs = shadow
}
setStrongFlags :: Bool -> DepResolverParams -> DepResolverParams
setStrongFlags b params =
setStrongFlags :: StrongFlags -> DepResolverParams -> DepResolverParams
setStrongFlags sf params =
params {
depResolverStrongFlags = b
depResolverStrongFlags = sf
}
setMaxBackjumps :: Maybe Int -> DepResolverParams -> DepResolverParams
......@@ -660,7 +661,7 @@ interpretPackagesPreference selected defaultPref prefs =
--
validateSolverResult :: Platform
-> CompilerInfo
-> Bool
-> IndependentGoals
-> [ResolverPackage UnresolvedPkgLoc]
-> SolverInstallPlan
validateSolverResult platform comp indepGoals pkgs =
......
......@@ -29,6 +29,7 @@ import qualified Distribution.Client.Dependency.Modular.PSQ as P
import Distribution.Client.Dependency.Modular.Tree
import Distribution.Client.ComponentDeps (Component)
import Distribution.Client.Dependency.Types (IndependentGoals(..))
-- | The state needed during the build phase of the search tree.
data BuildState = BS {
......@@ -172,8 +173,8 @@ build = ana go
-- | Interface to the tree builder. Just takes an index and a list of package names,
-- and computes the initial state and then the tree from there.
buildTree :: Index -> Bool -> [PN] -> Tree QGoalReason
buildTree idx ind igs =
buildTree :: Index -> IndependentGoals -> [PN] -> Tree QGoalReason
buildTree idx (IndependentGoals ind) igs =
build BS {
index = idx
, rdeps = M.fromList (L.map (\ qpn -> (qpn, [])) qpns)
......
......@@ -12,6 +12,7 @@ import Prelude hiding (pi)
import qualified Distribution.Client.PackageIndex as CI
import Distribution.Client.Types
import Distribution.Client.ComponentDeps (Component(..))
import Distribution.Client.Dependency.Types
import Distribution.Compiler
import Distribution.InstalledPackageInfo as IPI
import Distribution.Package -- from Cabal
......@@ -38,15 +39,15 @@ import Distribution.Client.Dependency.Modular.Version
-- resolving these situations. However, the right thing to do is to
-- fix the problem there, so for now, shadowing is only activated if
-- explicitly requested.
convPIs :: OS -> Arch -> CompilerInfo -> Bool -> Bool ->
convPIs :: OS -> Arch -> CompilerInfo -> ShadowPkgs -> StrongFlags ->
SI.InstalledPackageIndex -> CI.PackageIndex (SourcePackage loc) -> Index
convPIs os arch comp sip strfl iidx sidx =
mkIndex (convIPI' sip iidx ++ convSPI' os arch comp strfl sidx)
-- | Convert a Cabal installed package index to the simpler,
-- more uniform index format of the solver.
convIPI' :: Bool -> SI.InstalledPackageIndex -> [(PN, I, PInfo)]
convIPI' sip idx =
convIPI' :: ShadowPkgs -> SI.InstalledPackageIndex -> [(PN, I, PInfo)]
convIPI' (ShadowPkgs sip) idx =
-- apply shadowing whenever there are multiple installed packages with
-- the same version
[ maybeShadow (convIP idx pkg)
......@@ -88,12 +89,12 @@ convIPId pn' idx ipid =
-- | Convert a cabal-install source package index to the simpler,
-- more uniform index format of the solver.
convSPI' :: OS -> Arch -> CompilerInfo -> Bool ->
convSPI' :: OS -> Arch -> CompilerInfo -> StrongFlags ->
CI.PackageIndex (SourcePackage loc) -> [(PN, I, PInfo)]
convSPI' os arch cinfo strfl = L.map (convSP os arch cinfo strfl) . CI.allPackages
-- | Convert a single source package into the solver-specific format.
convSP :: OS -> Arch -> CompilerInfo -> Bool -> SourcePackage loc -> (PN, I, PInfo)
convSP :: OS -> Arch -> CompilerInfo -> StrongFlags -> SourcePackage loc -> (PN, I, PInfo)
convSP os arch cinfo strfl (SourcePackage (PackageIdentifier pn pv) gpd _ _pl) =
let i = I pv InRepo
in (pn, i, convGPD os arch cinfo strfl (PI pn i) gpd)
......@@ -103,7 +104,7 @@ convSP os arch cinfo strfl (SourcePackage (PackageIdentifier pn pv) gpd _ _pl) =
-- want to keep the condition tree, but simplify much of the test.
-- | Convert a generic package description to a solver-specific 'PInfo'.
convGPD :: OS -> Arch -> CompilerInfo -> Bool ->
convGPD :: OS -> Arch -> CompilerInfo -> StrongFlags ->
PI PN -> GenericPackageDescription -> PInfo
convGPD os arch cinfo strfl pi@(PI pn _)
(GenericPackageDescription pkg flags libs exes tests benchs) =
......@@ -188,8 +189,9 @@ prefix f fds = [f (concat fds)]
-- | Convert flag information. Automatic flags are now considered weak
-- unless strong flags have been selected explicitly.
flagInfo :: Bool -> [PD.Flag] -> FlagInfo
flagInfo strfl = M.fromList . L.map (\ (MkFlag fn _ b m) -> (fn, FInfo b m (not (strfl || m))))
flagInfo :: StrongFlags -> [PD.Flag] -> FlagInfo
flagInfo (StrongFlags strfl) =
M.fromList . L.map (\ (MkFlag fn _ b m) -> (fn, FInfo b m (not (strfl || m))))
-- | Internal package names, which should not be interpreted as true
-- dependencies.
......
......@@ -26,11 +26,11 @@ import Distribution.Client.Dependency.Modular.Linking
-- | Various options for the modular solver.
data SolverConfig = SolverConfig {
preferEasyGoalChoices :: Bool,
independentGoals :: Bool,
avoidReinstalls :: Bool,
shadowPkgs :: Bool,
strongFlags :: Bool,
preferEasyGoalChoices :: ReorderGoals,
independentGoals :: IndependentGoals,
avoidReinstalls :: AvoidReinstalls,
shadowPkgs :: ShadowPkgs,
strongFlags :: StrongFlags,
maxBackjumps :: Maybe Int,
enableBackjumping :: EnableBackjumping
}
......@@ -78,7 +78,7 @@ solve sc cinfo idx pkgConfigDB userPrefs userConstraints userGoals =
buildPhase
where
explorePhase = backjumpAndExplore (enableBackjumping sc)
heuristicsPhase = (if preferEasyGoalChoices sc
heuristicsPhase = (if unReorderGoals (preferEasyGoalChoices sc)
then P.preferEasyGoalChoices -- also leaves just one choice
else P.firstGoal) . -- after doing goal-choice heuristics, commit to the first choice (saves space)
P.deferWeakFlagChoices .
......@@ -91,7 +91,7 @@ solve sc cinfo idx pkgConfigDB userPrefs userConstraints userGoals =
P.enforceSingleInstanceRestriction .
validateLinking idx .
validateTree cinfo idx pkgConfigDB
prunePhase = (if avoidReinstalls sc then P.avoidReinstalls (const True) else id) .
prunePhase = (if unAvoidReinstalls (avoidReinstalls sc) then P.avoidReinstalls (const True) else id) .
-- packages that can never be "upgraded":
P.requireInstalled (`elem` [ PackageName "base"
, PackageName "ghc-prim"
......
......@@ -16,7 +16,14 @@
module Distribution.Client.Dependency.Types (
PreSolver(..),
Solver(..),
ReorderGoals(..),
IndependentGoals(..),
AvoidReinstalls(..),
ShadowPkgs(..),
StrongFlags(..),
EnableBackjumping(..),
DependencyResolver,
ResolverPackage(..),
......@@ -106,9 +113,30 @@ instance Text PreSolver where
"choose" -> return Choose
_ -> Parse.pfail
newtype ReorderGoals = ReorderGoals { unReorderGoals :: Bool }
deriving (Eq, Generic, Show)
newtype IndependentGoals = IndependentGoals { unIndependentGoals :: Bool }
deriving (Eq, Generic, Show)
newtype AvoidReinstalls = AvoidReinstalls { unAvoidReinstalls :: Bool }
deriving (Eq, Generic, Show)
newtype ShadowPkgs = ShadowPkgs { unShadowPkgs :: Bool }
deriving (Eq, Generic, Show)
newtype StrongFlags = StrongFlags { unStrongFlags :: Bool }
deriving (Eq, Generic, Show)
newtype EnableBackjumping = EnableBackjumping Bool
deriving Show
instance Binary ReorderGoals
instance Binary IndependentGoals
instance Binary AvoidReinstalls
instance Binary ShadowPkgs
instance Binary StrongFlags
-- | A dependency resolver is a function that works out an installation plan
-- given the set of installed and available packages and a set of deps to
-- solve for.
......
......@@ -61,6 +61,8 @@ import Distribution.InstalledPackageInfo
import Distribution.Package
( PackageIdentifier(..), PackageName(..), Package(..)
, HasUnitId(..), UnitId(..) )
import Distribution.Client.Dependency.Types
( IndependentGoals(..) )
import Distribution.Client.Types
( BuildSuccess, BuildFailure
, PackageFixedDeps(..)
......@@ -201,7 +203,7 @@ instance (HasUnitId ipkg, HasUnitId srcpkg) =>
data GenericInstallPlan ipkg srcpkg iresult ifailure = GenericInstallPlan {
planIndex :: !(PlanIndex ipkg srcpkg iresult ifailure),
planIndepGoals :: !Bool,
planIndepGoals :: !IndependentGoals,
-- | Cached (lazily) graph
--
......@@ -296,7 +298,7 @@ invariant plan =
mkInstallPlan :: (HasUnitId ipkg, PackageFixedDeps ipkg,
HasUnitId srcpkg, PackageFixedDeps srcpkg)
=> PlanIndex ipkg srcpkg iresult ifailure
-> Bool
-> IndependentGoals
-> GenericInstallPlan ipkg srcpkg iresult ifailure
mkInstallPlan index indepGoals =
GenericInstallPlan {
......@@ -354,7 +356,7 @@ showPlanPackageTag (Failed _ _) = "Failed"
--
new :: (HasUnitId ipkg, PackageFixedDeps ipkg,
HasUnitId srcpkg, PackageFixedDeps srcpkg)
=> Bool
=> IndependentGoals
-> PlanIndex ipkg srcpkg iresult ifailure
-> Either [PlanProblem ipkg srcpkg iresult ifailure]
(GenericInstallPlan ipkg srcpkg iresult ifailure)
......@@ -619,7 +621,7 @@ mapPreservingGraph f plan =
--
valid :: (HasUnitId ipkg, PackageFixedDeps ipkg,
HasUnitId srcpkg, PackageFixedDeps srcpkg)
=> Bool
=> IndependentGoals
-> PlanIndex ipkg srcpkg iresult ifailure
-> Bool
valid indepGoals index =
......@@ -671,7 +673,7 @@ showPlanProblem (PackageStateInvalid pkg pkg') =
--
problems :: (HasUnitId ipkg, PackageFixedDeps ipkg,
HasUnitId srcpkg, PackageFixedDeps srcpkg)
=> Bool
=> IndependentGoals
-> PlanIndex ipkg srcpkg iresult ifailure
-> [PlanProblem ipkg srcpkg iresult ifailure]
problems indepGoals index =
......@@ -737,7 +739,7 @@ closed = null . PlanIndex.brokenPackages
consistent :: (HasUnitId ipkg, PackageFixedDeps ipkg,
HasUnitId srcpkg, PackageFixedDeps srcpkg)
=> PlanIndex ipkg srcpkg iresult ifailure -> Bool
consistent = null . PlanIndex.dependencyInconsistencies False
consistent = null . PlanIndex.dependencyInconsistencies (IndependentGoals False)
-- | The states of packages have that depend on each other must respect
-- this relation. That is for very case where package @a@ depends on
......
......@@ -32,6 +32,7 @@ import Distribution.Version
( Version )
import qualified Distribution.Client.ComponentDeps as CD
import Distribution.Client.Dependency.Types
import Distribution.Client.Types
( PackageFixedDeps(..) )
import Distribution.Simple.PackageIndex
......@@ -62,7 +63,7 @@ brokenPackages index =
-- cycle. Such cycles may or may not be an issue; either way, we don't check
-- for them here.
dependencyInconsistencies :: forall pkg. (PackageFixedDeps pkg, HasUnitId pkg)
=> Bool
=> IndependentGoals
-> PackageIndex pkg
-> [(PackageName, [(PackageIdentifier, Version)])]
dependencyInconsistencies indepGoals index =
......@@ -80,8 +81,8 @@ dependencyInconsistencies indepGoals index =
-- as singletons sets if we are considering them as independent goals), along
-- with all setup dependencies of all packages.
rootSets :: (PackageFixedDeps pkg, HasUnitId pkg)
=> Bool -> PackageIndex pkg -> [[UnitId]]
rootSets indepGoals index =
=> IndependentGoals -> PackageIndex pkg -> [[UnitId]]
rootSets (IndependentGoals indepGoals) index =
if indepGoals then map (:[]) libRoots else [libRoots]
++ setupRoots index
where
......
......@@ -47,6 +47,8 @@ import Distribution.Client.Glob
( isTrivialFilePathGlob )
import Distribution.Client.Types
import Distribution.Client.Dependency.Types
( ReorderGoals(..), StrongFlags(..) )
import Distribution.Client.DistDirLayout
( CabalDirLayout(..) )
import Distribution.Client.GlobalFlags
......@@ -205,8 +207,8 @@ resolveSolverSettings ProjectConfig{
projectConfigSolver = Flag defaultSolver,
projectConfigAllowNewer = Just AllowNewerNone,
projectConfigMaxBackjumps = Flag defaultMaxBackjumps,
projectConfigReorderGoals = Flag False,
projectConfigStrongFlags = Flag False
projectConfigReorderGoals = Flag (ReorderGoals False),
projectConfigStrongFlags = Flag (StrongFlags False)
--projectConfigIndependentGoals = Flag False,
--projectConfigShadowPkgs = Flag False,
--projectConfigReinstall = Flag False,
......
......@@ -22,7 +22,7 @@ module Distribution.Client.ProjectConfig.Types (
import Distribution.Client.Types
( RemoteRepo )
import Distribution.Client.Dependency.Types
( PreSolver, ConstraintSource )
( PreSolver, ConstraintSource, ReorderGoals, StrongFlags )
import Distribution.Client.Targets
( UserConstraint )
import Distribution.Client.BuildReports.Types
......@@ -161,8 +161,8 @@ data ProjectConfigShared
projectConfigSolver :: Flag PreSolver,
projectConfigAllowNewer :: Maybe AllowNewer,
projectConfigMaxBackjumps :: Flag Int,
projectConfigReorderGoals :: Flag Bool,
projectConfigStrongFlags :: Flag Bool
projectConfigReorderGoals :: Flag ReorderGoals,
projectConfigStrongFlags :: Flag StrongFlags
-- More things that only make sense for manual mode, not --local mode
-- too much control!
......@@ -315,8 +315,8 @@ data SolverSettings
solverSettingSolver :: PreSolver,
solverSettingAllowNewer :: AllowNewer,
solverSettingMaxBackjumps :: Maybe Int,
solverSettingReorderGoals :: Bool,
solverSettingStrongFlags :: Bool
solverSettingReorderGoals :: ReorderGoals,
solverSettingStrongFlags :: StrongFlags
-- Things that only make sense for manual mode, not --local mode
-- too much control!
--solverSettingIndependentGoals :: Bool,
......
......@@ -1409,7 +1409,7 @@ pruneInstallPlanToTargets :: Map InstalledPackageId [PackageTarget]
-> ElaboratedInstallPlan -> ElaboratedInstallPlan
pruneInstallPlanToTargets perPkgTargetsMap =
either (\_ -> assert False undefined) id
. InstallPlan.new False
. InstallPlan.new (IndependentGoals False)
. PackageIndex.fromList
-- We have to do this in two passes
. pruneInstallPlanPass2
......
......@@ -59,7 +59,9 @@ import Distribution.Client.Types
import Distribution.Client.BuildReports.Types
( ReportLevel(..) )
import Distribution.Client.Dependency.Types
( PreSolver(..), ConstraintSource(..) )
( PreSolver(..), ConstraintSource(..), ReorderGoals(..)
, IndependentGoals(..), AvoidReinstalls(..), ShadowPkgs(..)
, StrongFlags(..) )
import qualified Distribution.Client.Init.Types as IT
( InitFlags(..), PackageType(..) )
import Distribution.Client.Targets
......@@ -602,10 +604,10 @@ data FetchFlags = FetchFlags {
fetchDryRun :: Flag Bool,
fetchSolver :: Flag PreSolver,
fetchMaxBackjumps :: Flag Int,
fetchReorderGoals :: Flag Bool,
fetchIndependentGoals :: Flag Bool,
fetchShadowPkgs :: Flag Bool,
fetchStrongFlags :: Flag Bool,
fetchReorderGoals :: Flag ReorderGoals,
fetchIndependentGoals :: Flag IndependentGoals,
fetchShadowPkgs :: Flag ShadowPkgs,
fetchStrongFlags :: Flag StrongFlags,
fetchVerbosity :: Flag Verbosity
}
......@@ -616,10 +618,10 @@ defaultFetchFlags = FetchFlags {
fetchDryRun = toFlag False,
fetchSolver = Flag defaultSolver,
fetchMaxBackjumps = Flag defaultMaxBackjumps,
fetchReorderGoals = Flag False,
fetchIndependentGoals = Flag False,
fetchShadowPkgs = Flag False,
fetchStrongFlags = Flag False,
fetchReorderGoals = Flag (ReorderGoals False),
fetchIndependentGoals = Flag (IndependentGoals False),
fetchShadowPkgs = Flag (ShadowPkgs False),
fetchStrongFlags = Flag (StrongFlags False),
fetchVerbosity = toFlag normal
}
......@@ -679,10 +681,10 @@ data FreezeFlags = FreezeFlags {
freezeBenchmarks :: Flag Bool,
freezeSolver :: Flag PreSolver,
freezeMaxBackjumps :: Flag Int,
freezeReorderGoals :: Flag Bool,
freezeIndependentGoals :: Flag Bool,
freezeShadowPkgs :: Flag Bool,
freezeStrongFlags :: Flag Bool,
freezeReorderGoals :: Flag ReorderGoals,
freezeIndependentGoals :: Flag IndependentGoals,
freezeShadowPkgs :: Flag ShadowPkgs,
freezeStrongFlags :: Flag StrongFlags,
freezeVerbosity :: Flag Verbosity
}
......@@ -693,10 +695,10 @@ defaultFreezeFlags = FreezeFlags {
freezeBenchmarks = toFlag False,
freezeSolver = Flag defaultSolver,
freezeMaxBackjumps = Flag defaultMaxBackjumps,
freezeReorderGoals = Flag False,
freezeIndependentGoals = Flag False,
freezeShadowPkgs = Flag False,
freezeStrongFlags = Flag False,
freezeReorderGoals = Flag (ReorderGoals False),
freezeIndependentGoals = Flag (IndependentGoals False),
freezeShadowPkgs = Flag (ShadowPkgs False),
freezeStrongFlags = Flag (StrongFlags False),
freezeVerbosity = toFlag normal
}
......@@ -1140,12 +1142,12 @@ data InstallFlags = InstallFlags {
installHaddockIndex :: Flag PathTemplate,
installDryRun :: Flag Bool,
installMaxBackjumps :: Flag Int,
installReorderGoals :: Flag Bool,
installIndependentGoals :: Flag Bool,
installShadowPkgs :: Flag Bool,
installStrongFlags :: Flag Bool,
installReorderGoals :: Flag ReorderGoals,
installIndependentGoals :: Flag IndependentGoals,
installShadowPkgs :: Flag ShadowPkgs,
installStrongFlags :: Flag StrongFlags,
installReinstall :: Flag Bool,
installAvoidReinstalls :: Flag Bool,
installAvoidReinstalls :: Flag AvoidReinstalls,
installOverrideReinstall :: Flag Bool,
installUpgradeDeps :: Flag Bool,
installOnly :: Flag Bool,
......@@ -1171,12 +1173,12 @@ defaultInstallFlags = InstallFlags {
installHaddockIndex = Flag docIndexFile,
installDryRun = Flag False,
installMaxBackjumps = Flag defaultMaxBackjumps,
installReorderGoals = Flag False,
installIndependentGoals= Flag False,
installShadowPkgs = Flag False,
installStrongFlags = Flag False,
installReorderGoals = Flag (ReorderGoals False),
installIndependentGoals= Flag (IndependentGoals False),
installShadowPkgs = Flag (ShadowPkgs False),
installStrongFlags = Flag (StrongFlags False),
installReinstall = Flag False,
installAvoidReinstalls = Flag False,
installAvoidReinstalls = Flag (AvoidReinstalls False),
installOverrideReinstall = Flag False,
installUpgradeDeps = Flag False,
installOnly = Flag False,
......@@ -1327,7 +1329,8 @@ installOptions showOrParseArgs =
, option [] ["avoid-reinstalls"]
"Do not select versions that would destructively overwrite installed packages."
installAvoidReinstalls (\v flags -> flags { installAvoidReinstalls = v })
(fmap unAvoidReinstalls . installAvoidReinstalls)
(\v flags -> flags { installAvoidReinstalls = fmap AvoidReinstalls v })
(yesNoOpt showOrParseArgs)
, option [] ["force-reinstalls"]
......@@ -2065,10 +2068,10 @@ optionSolver get set =
optionSolverFlags :: ShowOrParseArgs
-> (flags -> Flag Int ) -> (Flag Int -> flags -> flags)
-> (flags -> Flag Bool ) -> (Flag Bool -> flags -> flags)
-> (flags -> Flag Bool ) -> (Flag Bool -> flags -> flags)
-> (flags -> Flag Bool ) -> (Flag Bool -> flags -> flags)
-> (flags -> Flag Bool ) -> (Flag Bool -> flags -> flags)
-> (flags -> Flag ReorderGoals) -> (Flag ReorderGoals -> flags -> flags)
-> (flags -> Flag IndependentGoals) -> (Flag IndependentGoals -> flags -> flags)
-> (flags -> Flag ShadowPkgs) -> (Flag ShadowPkgs -> flags -> flags)
-> (flags -> Flag StrongFlags) -> (Flag StrongFlags -> flags -> flags)
-> [OptionField flags]
optionSolverFlags showOrParseArgs getmbj setmbj getrg setrg _getig _setig getsip setsip getstrfl setstrfl =
[ option [] ["max-backjumps"]
......@@ -2078,7 +2081,8 @@ optionSolverFlags showOrParseArgs getmbj setmbj getrg setrg _getig _setig getsip
(map show . flagToList))
, option [] ["reorder-goals"]
"Try to reorder goals according to certain heuristics. Slows things down on average, but may make backtracking faster for some packages."
getrg setrg
(fmap unReorderGoals . getrg)
(setrg . fmap ReorderGoals)
(yesNoOpt showOrParseArgs)
-- TODO: Disabled for now because it does not work as advertised (yet).
{-
......@@ -2089,11 +2093,13 @@ optionSolverFlags showOrParseArgs getmbj setmbj getrg setrg _getig _setig getsip
-}
, option [] ["shadow-installed-packages"]
"If multiple package instances of the same version are installed, treat all but one as shadowed."
getsip setsip
(fmap unShadowPkgs . getsip)
(setsip . fmap ShadowPkgs)
(yesNoOpt showOrParseArgs)
, option [] ["strong-flags"]
"Do not defer flag choices (this used to be the default in cabal-install <= 1.20)."
getstrfl setstrfl
(fmap unStrongFlags . getstrfl)
(setstrfl . fmap StrongFlags)
(yesNoOpt showOrParseArgs)
]
......
......@@ -11,8 +11,6 @@ module UnitTests.Distribution.Client.Dependency.Modular.DSL (
, ExamplePkgName
, ExampleAvailable(..)
, ExampleInstalled(..)
, IndepGoals(..)
, ReorderGoals(..)
, exAv
, exInst
, exFlag
......@@ -195,12 +193,6 @@ type ExampleDb = [Either ExampleInstalled ExampleAvailable]
type DependencyTree a = C.CondTree C.ConfVar [C.Dependency] a
newtype IndepGoals = IndepGoals Bool
deriving Show
newtype ReorderGoals = ReorderGoals Bool
deriving Show
exDbPkgs :: ExampleDb -> [ExamplePkgName]
exDbPkgs = map (either exInstName exAvName)
......@@ -396,13 +388,13 @@ exResolve :: ExampleDb
-> [ExamplePkgName]
-> Solver
-> Maybe Int
-> IndepGoals
-> IndependentGoals
-> ReorderGoals
-> EnableBackjumping
-> [ExPreference]
-> ([String], Either String CI.InstallPlan.SolverInstallPlan)
exResolve db exts langs pkgConfigDb targets solver mbj (IndepGoals indepGoals)
(ReorderGoals reorder) enableBj prefs
exResolve db exts langs pkgConfigDb targets solver mbj indepGoals reorder
enableBj prefs
= runProgress $ resolveDependencies C.buildPlatform
compiler pkgConfigDb
solver
......
......@@ -19,9 +19,11 @@ import Test.Tasty (TestTree)
import Test.Tasty.QuickCheck
import qualified Distribution.Client.ComponentDeps as CD
import Distribution.Client.ComponentDeps ( Component(..)
, ComponentDep, ComponentDeps)
import Distribution.Client.Dependency.Types (EnableBackjumping(..), Solver(..))
import Distribution.Client.ComponentDeps