1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
module Distribution.Client.Dependency.Modular.Solver where
import Data.Map as M
import Distribution.Client.Dependency.Types
import Distribution.Client.Dependency.Modular.Assignment
import Distribution.Client.Dependency.Modular.Builder
import Distribution.Client.Dependency.Modular.Dependency
import Distribution.Client.Dependency.Modular.Explore
import Distribution.Client.Dependency.Modular.Index
import Distribution.Client.Dependency.Modular.Log
import Distribution.Client.Dependency.Modular.Message
import Distribution.Client.Dependency.Modular.Package
import qualified Distribution.Client.Dependency.Modular.Preference as P
import Distribution.Client.Dependency.Modular.Validate
-- | Various options for the modular solver.
data SolverConfig = SolverConfig {
preferEasyGoalChoices :: Bool,
independentGoals :: Bool,
avoidReinstalls :: Bool,
shadowPkgs :: Bool,
strongFlags :: Bool,
maxBackjumps :: Maybe Int
}
solve :: SolverConfig -> -- solver parameters
Index -> -- all available packages as an index
(PN -> PackagePreferences) -> -- preferences
Map PN [PackageConstraint] -> -- global constraints
[PN] -> -- global goals
Log Message (Assignment, RevDepMap)
solve sc idx userPrefs userConstraints userGoals =
explorePhase $
heuristicsPhase $
preferencesPhase $
validationPhase $
prunePhase $
buildPhase
where
explorePhase = exploreTreeLog . backjump
heuristicsPhase = P.firstGoal . -- after doing goal-choice heuristics, commit to the first choice (saves space)
P.deferWeakFlagChoices .
P.preferBaseGoalChoice .
if preferEasyGoalChoices sc
then P.lpreferEasyGoalChoices
else id
preferencesPhase = P.preferPackagePreferences userPrefs
validationPhase = P.enforceManualFlags . -- can only be done after user constraints
P.enforcePackageConstraints userConstraints .
validateTree idx
prunePhase = (if avoidReinstalls sc then P.avoidReinstalls (const True) else id) .
-- packages that can never be "upgraded":
P.requireInstalled (`elem` [ PackageName "base"
, PackageName "ghc-prim"
, PackageName "integer-gmp"
, PackageName "integer-simple"
])
buildPhase = buildTree idx (independentGoals sc) userGoals
|