Copyright | (c) David Himmelstrup 2005 Bjorn Bringert 2007 Duncan Coutts 2008 |
---|---|
License | BSD-like |
Maintainer | cabal-devel@gmail.com |
Stability | provisional |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Distribution.Client.Dependency
Description
Top level interface to dependency resolution.
Synopsis
- data DepResolverParams
- chooseSolver :: Verbosity -> PreSolver -> CompilerInfo -> IO Solver
- resolveDependencies :: Platform -> CompilerInfo -> PkgConfigDb -> Solver -> DepResolverParams -> Progress String String SolverInstallPlan
- data Progress step fail done
- foldProgress :: (step -> a -> a) -> (fail -> a) -> (done -> a) -> Progress step fail done -> a
- resolveWithoutDependencies :: DepResolverParams -> Either [ResolveNoDepsError] [UnresolvedSourcePackage]
- data PackageProperty
- = PackagePropertyVersion VersionRange
- | PackagePropertyInstalled
- | PackagePropertySource
- | PackagePropertyFlags FlagAssignment
- | PackagePropertyStanzas [OptionalStanza]
- data PackageConstraint = PackageConstraint ConstraintScope PackageProperty
- scopeToplevel :: PackageName -> ConstraintScope
- data PackagesPreferenceDefault
- data PackagePreference
- = PackageVersionPreference PackageName VersionRange
- | PackageInstalledPreference PackageName InstalledPreference
- | PackageStanzasPreference PackageName [OptionalStanza]
- basicInstallPolicy :: InstalledPackageIndex -> SourcePackageDb -> [PackageSpecifier UnresolvedSourcePackage] -> DepResolverParams
- standardInstallPolicy :: InstalledPackageIndex -> SourcePackageDb -> [PackageSpecifier UnresolvedSourcePackage] -> DepResolverParams
- data PackageSpecifier pkg
- = NamedPackage PackageName [PackageProperty]
- | SpecificSourcePackage pkg
- upgradeDependencies :: DepResolverParams -> DepResolverParams
- reinstallTargets :: DepResolverParams -> DepResolverParams
- addConstraints :: [LabeledPackageConstraint] -> DepResolverParams -> DepResolverParams
- addPreferences :: [PackagePreference] -> DepResolverParams -> DepResolverParams
- setPreferenceDefault :: PackagesPreferenceDefault -> DepResolverParams -> DepResolverParams
- setReorderGoals :: ReorderGoals -> DepResolverParams -> DepResolverParams
- setCountConflicts :: CountConflicts -> DepResolverParams -> DepResolverParams
- setFineGrainedConflicts :: FineGrainedConflicts -> DepResolverParams -> DepResolverParams
- setMinimizeConflictSet :: MinimizeConflictSet -> DepResolverParams -> DepResolverParams
- setIndependentGoals :: IndependentGoals -> DepResolverParams -> DepResolverParams
- setAvoidReinstalls :: AvoidReinstalls -> DepResolverParams -> DepResolverParams
- setShadowPkgs :: ShadowPkgs -> DepResolverParams -> DepResolverParams
- setStrongFlags :: StrongFlags -> DepResolverParams -> DepResolverParams
- setAllowBootLibInstalls :: AllowBootLibInstalls -> DepResolverParams -> DepResolverParams
- setOnlyConstrained :: OnlyConstrained -> DepResolverParams -> DepResolverParams
- setMaxBackjumps :: Maybe Int -> DepResolverParams -> DepResolverParams
- setEnableBackjumping :: EnableBackjumping -> DepResolverParams -> DepResolverParams
- setSolveExecutables :: SolveExecutables -> DepResolverParams -> DepResolverParams
- setGoalOrder :: Maybe (Variable QPN -> Variable QPN -> Ordering) -> DepResolverParams -> DepResolverParams
- setSolverVerbosity :: Verbosity -> DepResolverParams -> DepResolverParams
- removeLowerBounds :: AllowOlder -> DepResolverParams -> DepResolverParams
- removeUpperBounds :: AllowNewer -> DepResolverParams -> DepResolverParams
- addDefaultSetupDependencies :: (UnresolvedSourcePackage -> Maybe [Dependency]) -> DepResolverParams -> DepResolverParams
- addSetupCabalMinVersionConstraint :: Version -> DepResolverParams -> DepResolverParams
- addSetupCabalMaxVersionConstraint :: Version -> DepResolverParams -> DepResolverParams
The main package dependency resolver
data DepResolverParams Source #
The set of parameters to the dependency resolver. These parameters are relatively low level but many kinds of high level policies can be implemented in terms of adjustments to the parameters.
resolveDependencies :: Platform -> CompilerInfo -> PkgConfigDb -> Solver -> DepResolverParams -> Progress String String SolverInstallPlan Source #
Run the dependency solver.
Since this is potentially an expensive operation, the result is wrapped in a
a Progress
structure that can be unfolded to provide progress information,
logging messages and the final result or an error.
data Progress step fail done #
Instances
Monoid fail => Alternative (Progress step fail) | |
Applicative (Progress step fail) | |
Defined in Distribution.Solver.Types.Progress Methods pure :: a -> Progress step fail a # (<*>) :: Progress step fail (a -> b) -> Progress step fail a -> Progress step fail b # liftA2 :: (a -> b -> c) -> Progress step fail a -> Progress step fail b -> Progress step fail c # (*>) :: Progress step fail a -> Progress step fail b -> Progress step fail b # (<*) :: Progress step fail a -> Progress step fail b -> Progress step fail a # | |
Functor (Progress step fail) | |
Monad (Progress step fail) | |
foldProgress :: (step -> a -> a) -> (fail -> a) -> (done -> a) -> Progress step fail done -> a #
Alternate, simple resolver that does not do dependencies recursively
resolveWithoutDependencies :: DepResolverParams -> Either [ResolveNoDepsError] [UnresolvedSourcePackage] Source #
A simplistic method of resolving a list of target package names to available packages.
Specifically, it does not consider package dependencies at all. Unlike
resolveDependencies
, no attempt is made to ensure that the selected
packages have dependencies that are satisfiable or consistent with
each other.
It is suitable for tasks such as selecting packages to download for user inspection. It is not suitable for selecting packages to install.
Note: if no installed package index is available, it is OK to pass mempty
.
It simply means preferences for installed packages will be ignored.
Constructing resolver policies
data PackageProperty #
Constructors
PackagePropertyVersion VersionRange | |
PackagePropertyInstalled | |
PackagePropertySource | |
PackagePropertyFlags FlagAssignment | |
PackagePropertyStanzas [OptionalStanza] |
Instances
Structured PackageProperty | |||||
Defined in Distribution.Solver.Types.PackageConstraint | |||||
Generic PackageProperty | |||||
Defined in Distribution.Solver.Types.PackageConstraint Associated Types
Methods from :: PackageProperty -> Rep PackageProperty x to :: Rep PackageProperty x -> PackageProperty | |||||
Show PackageProperty | |||||
Defined in Distribution.Solver.Types.PackageConstraint Methods showsPrec :: Int -> PackageProperty -> ShowS # show :: PackageProperty -> String # showList :: [PackageProperty] -> ShowS # | |||||
Binary PackageProperty | |||||
Defined in Distribution.Solver.Types.PackageConstraint Methods put :: PackageProperty -> Put # get :: Get PackageProperty # putList :: [PackageProperty] -> Put # | |||||
Eq PackageProperty | |||||
Defined in Distribution.Solver.Types.PackageConstraint Methods (==) :: PackageProperty -> PackageProperty -> Bool # (/=) :: PackageProperty -> PackageProperty -> Bool # | |||||
type Rep PackageProperty | |||||
Defined in Distribution.Solver.Types.PackageConstraint type Rep PackageProperty = D1 ('MetaData "PackageProperty" "Distribution.Solver.Types.PackageConstraint" "cabal-install-solver-3.10.3.0-KuDy3NjZ2Gt3ckFY1mGRio" 'False) ((C1 ('MetaCons "PackagePropertyVersion" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 VersionRange)) :+: C1 ('MetaCons "PackagePropertyInstalled" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "PackagePropertySource" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PackagePropertyFlags" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FlagAssignment)) :+: C1 ('MetaCons "PackagePropertyStanzas" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [OptionalStanza]))))) |
data PackageConstraint #
Constructors
PackageConstraint ConstraintScope PackageProperty |
Instances
Show PackageConstraint | |
Defined in Distribution.Solver.Types.PackageConstraint Methods showsPrec :: Int -> PackageConstraint -> ShowS # show :: PackageConstraint -> String # showList :: [PackageConstraint] -> ShowS # | |
Eq PackageConstraint | |
Defined in Distribution.Solver.Types.PackageConstraint Methods (==) :: PackageConstraint -> PackageConstraint -> Bool # (/=) :: PackageConstraint -> PackageConstraint -> Bool # |
scopeToplevel :: PackageName -> ConstraintScope #
data PackagesPreferenceDefault Source #
Global policy for all packages to say if we prefer package versions that are already installed locally or if we just prefer the latest available.
Constructors
PreferAllLatest | Always prefer the latest version irrespective of any existing installed version.
|
PreferAllOldest | Always prefer the oldest version irrespective of any existing installed version or packages explicitly requested.
|
PreferAllInstalled | Always prefer the installed versions over ones that would need to be installed. Secondarily, prefer latest versions (eg the latest installed version or if there are none then the latest source version). |
PreferLatestForSelected | Prefer the latest version for packages that are explicitly requested but prefers the installed version for any other packages.
|
Instances
Show PackagesPreferenceDefault Source # | |
Defined in Distribution.Client.Dependency.Types Methods showsPrec :: Int -> PackagesPreferenceDefault -> ShowS # show :: PackagesPreferenceDefault -> String # showList :: [PackagesPreferenceDefault] -> ShowS # |
data PackagePreference Source #
A package selection preference for a particular package.
Preferences are soft constraints that the dependency resolver should try to respect where possible. It is not specified if preferences on some packages are more important than others.
Constructors
PackageVersionPreference PackageName VersionRange | A suggested constraint on the version number. |
PackageInstalledPreference PackageName InstalledPreference | If we prefer versions of packages that are already installed. |
PackageStanzasPreference PackageName [OptionalStanza] | If we would prefer to enable these optional stanzas (i.e. test suites and/or benchmarks) |
Standard policy
basicInstallPolicy :: InstalledPackageIndex -> SourcePackageDb -> [PackageSpecifier UnresolvedSourcePackage] -> DepResolverParams Source #
A basic solver policy on which all others are built.
standardInstallPolicy :: InstalledPackageIndex -> SourcePackageDb -> [PackageSpecifier UnresolvedSourcePackage] -> DepResolverParams Source #
The policy used by all the standard commands, install, fetch, freeze etc (but not the v2-build and related commands).
It extends the basicInstallPolicy
with a policy on setup deps.
data PackageSpecifier pkg Source #
A fully or partially resolved reference to a package.
Constructors
NamedPackage PackageName [PackageProperty] | A partially specified reference to a package (either source or installed). It is specified by package name and optionally some required properties. Use a dependency resolver to pick a specific package satisfying these properties. |
SpecificSourcePackage pkg | A fully specified source package. |
Instances
Functor PackageSpecifier Source # | |||||
Defined in Distribution.Client.Types.PackageSpecifier Methods fmap :: (a -> b) -> PackageSpecifier a -> PackageSpecifier b # (<$) :: a -> PackageSpecifier b -> PackageSpecifier a # | |||||
Structured pkg => Structured (PackageSpecifier pkg) Source # | |||||
Defined in Distribution.Client.Types.PackageSpecifier Methods structure :: Proxy (PackageSpecifier pkg) -> Structure structureHash' :: Tagged (PackageSpecifier pkg) MD5 | |||||
Generic (PackageSpecifier pkg) Source # | |||||
Defined in Distribution.Client.Types.PackageSpecifier Associated Types
Methods from :: PackageSpecifier pkg -> Rep (PackageSpecifier pkg) x to :: Rep (PackageSpecifier pkg) x -> PackageSpecifier pkg | |||||
Show pkg => Show (PackageSpecifier pkg) Source # | |||||
Defined in Distribution.Client.Types.PackageSpecifier Methods showsPrec :: Int -> PackageSpecifier pkg -> ShowS # show :: PackageSpecifier pkg -> String # showList :: [PackageSpecifier pkg] -> ShowS # | |||||
Binary pkg => Binary (PackageSpecifier pkg) Source # | |||||
Defined in Distribution.Client.Types.PackageSpecifier Methods put :: PackageSpecifier pkg -> Put # get :: Get (PackageSpecifier pkg) # putList :: [PackageSpecifier pkg] -> Put # | |||||
Eq pkg => Eq (PackageSpecifier pkg) Source # | |||||
Defined in Distribution.Client.Types.PackageSpecifier Methods (==) :: PackageSpecifier pkg -> PackageSpecifier pkg -> Bool # (/=) :: PackageSpecifier pkg -> PackageSpecifier pkg -> Bool # | |||||
type Rep (PackageSpecifier pkg) Source # | |||||
Defined in Distribution.Client.Types.PackageSpecifier type Rep (PackageSpecifier pkg) = D1 ('MetaData "PackageSpecifier" "Distribution.Client.Types.PackageSpecifier" "cabal-install-3.10.3.0-5JencM0rYHKlSNVQlqPWT" 'False) (C1 ('MetaCons "NamedPackage" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [PackageProperty])) :+: C1 ('MetaCons "SpecificSourcePackage" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 pkg))) |
Extra policy options
Policy utils
addConstraints :: [LabeledPackageConstraint] -> DepResolverParams -> DepResolverParams Source #
setPreferenceDefault :: PackagesPreferenceDefault -> DepResolverParams -> DepResolverParams Source #
setReorderGoals :: ReorderGoals -> DepResolverParams -> DepResolverParams Source #
setCountConflicts :: CountConflicts -> DepResolverParams -> DepResolverParams Source #
setFineGrainedConflicts :: FineGrainedConflicts -> DepResolverParams -> DepResolverParams Source #
setMinimizeConflictSet :: MinimizeConflictSet -> DepResolverParams -> DepResolverParams Source #
setIndependentGoals :: IndependentGoals -> DepResolverParams -> DepResolverParams Source #
setAvoidReinstalls :: AvoidReinstalls -> DepResolverParams -> DepResolverParams Source #
setShadowPkgs :: ShadowPkgs -> DepResolverParams -> DepResolverParams Source #
setStrongFlags :: StrongFlags -> DepResolverParams -> DepResolverParams Source #
setAllowBootLibInstalls :: AllowBootLibInstalls -> DepResolverParams -> DepResolverParams Source #
setOnlyConstrained :: OnlyConstrained -> DepResolverParams -> DepResolverParams Source #
setEnableBackjumping :: EnableBackjumping -> DepResolverParams -> DepResolverParams Source #
setSolveExecutables :: SolveExecutables -> DepResolverParams -> DepResolverParams Source #
setGoalOrder :: Maybe (Variable QPN -> Variable QPN -> Ordering) -> DepResolverParams -> DepResolverParams Source #
removeLowerBounds :: AllowOlder -> DepResolverParams -> DepResolverParams Source #
Dual of removeUpperBounds
removeUpperBounds :: AllowNewer -> DepResolverParams -> DepResolverParams Source #
Remove upper bounds in dependencies using the policy specified by the
AllowNewer
argument (allsomenone).
Note: It's important to apply removeUpperBounds
after
addSourcePackages
. Otherwise, the packages inserted by
addSourcePackages
won't have upper bounds in dependencies relaxed.
addDefaultSetupDependencies :: (UnresolvedSourcePackage -> Maybe [Dependency]) -> DepResolverParams -> DepResolverParams Source #
Supply defaults for packages without explicit Setup dependencies
Note: It's important to apply addDefaultSetupDepends
after
addSourcePackages
. Otherwise, the packages inserted by
addSourcePackages
won't have upper bounds in dependencies relaxed.
addSetupCabalMinVersionConstraint :: Version -> DepResolverParams -> DepResolverParams Source #
If a package has a custom setup then we need to add a setup-depends on Cabal.
addSetupCabalMaxVersionConstraint :: Version -> DepResolverParams -> DepResolverParams Source #
Variant of addSetupCabalMinVersionConstraint
which sets an
upper bound on setup.Cabal
labeled with ConstraintSetupCabalMaxVersion
.