cabal-install-solver-3.12.1.0: The command-line interface for Cabal and Hackage.

Safe Haskell | None
Language | Haskell2010

Distribution.Solver.Modular.Dependency

Contents

- Variables
- Conflict sets
- Constrained instances
- Flagged dependencies
- Reverse dependency map
- Goals

Synopsis

- data Var qpn
  - = P qpn
  - | F (FN qpn)
  - | S (SN qpn)
- showVar :: Var QPN -> String
- varPN :: Var qpn -> qpn
- data ConflictSet
- type ConflictMap = Map (Var QPN) Int
- showConflictSet :: ConflictSet -> String
- data CI
  - = Fixed I
  - | Constrained VR
- type FlaggedDeps qpn = [FlaggedDep qpn]
- data FlaggedDep qpn
  - = Flagged (FN qpn) FInfo (TrueFlaggedDeps qpn) (FalseFlaggedDeps qpn)
  - | Stanza (SN qpn) (TrueFlaggedDeps qpn)
  - | Simple (LDep qpn) Component
- data LDep qpn = LDep (DependencyReason qpn) (Dep qpn)
- data Dep qpn
  - = Dep (PkgComponent qpn) CI
  - | Ext Extension
  - | Lang Language
  - | Pkg PkgconfigName PkgconfigVersionRange
- data PkgComponent qpn = PkgComponent qpn ExposedComponent
- data ExposedComponent
  - = ExposedLib LibraryName
  - | ExposedExe UnqualComponentName
- data DependencyReason qpn = DependencyReason qpn (Map Flag FlagValue) (Set Stanza)
- showDependencyReason :: DependencyReason QPN -> String
- flattenFlaggedDeps :: FlaggedDeps qpn -> [(LDep qpn, Component)]
- data QualifyOptions = QO {
  - qoBaseShim :: Bool
  - qoSetupIndependent :: Bool
  }
- qualifyDeps :: QualifyOptions -> QPN -> FlaggedDeps PN -> FlaggedDeps QPN
- unqualifyDeps :: FlaggedDeps QPN -> FlaggedDeps PN
- type RevDepMap = Map QPN [(Component, QPN)]
- data Goal qpn = Goal (Var qpn) (GoalReason qpn)
- data GoalReason qpn
  - = UserGoal
  - | DependencyGoal (DependencyReason qpn)
- type QGoalReason = GoalReason QPN
- goalToVar :: Goal a -> Var a
- varToConflictSet :: Var QPN -> ConflictSet
- goalReasonToConflictSet :: GoalReason QPN -> ConflictSet
- goalReasonToConflictSetWithConflict :: QPN -> GoalReason QPN -> ConflictSet
- dependencyReasonToConflictSet :: DependencyReason QPN -> ConflictSet
- dependencyReasonToConflictSetWithVersionConstraintConflict :: QPN -> Ver -> DependencyReason QPN -> ConflictSet
- dependencyReasonToConflictSetWithVersionConflict :: QPN -> OrderedVersionRange -> DependencyReason QPN -> ConflictSet

# Variables

data Var qpn Source #

The type of variables that play a role in the solver. Note that the tree currently does not use this type directly, and rather has separate tree nodes for the different types of variables. This fits better with the fact that in most cases, these have to be treated differently.

Constructors

P qpn |
F (FN qpn) |
S (SN qpn) |

#### Instances

Instances details

Functor Var Source # |
Instance details Defined in Distribution.Solver.Modular.Var Methods fmap :: (a -> b) -> Var a -> Var b Source # (<$) :: a -> Var b -> Var a Source #
Show qpn => Show (Var qpn) Source # |
Instance details Defined in Distribution.Solver.Modular.Var Methods showsPrec :: Int -> Var qpn -> ShowS Source # show :: Var qpn -> String Source # showList :: [Var qpn] -> ShowS Source #
Eq qpn => Eq (Var qpn) Source # |
Instance details Defined in Distribution.Solver.Modular.Var Methods (==) :: Var qpn -> Var qpn -> Bool Source # (/=) :: Var qpn -> Var qpn -> Bool Source #
Ord qpn => Ord (Var qpn) Source # |
Instance details Defined in Distribution.Solver.Modular.Var Methods compare :: Var qpn -> Var qpn -> Ordering Source # (<) :: Var qpn -> Var qpn -> Bool Source # (<=) :: Var qpn -> Var qpn -> Bool Source # (>) :: Var qpn -> Var qpn -> Bool Source # (>=) :: Var qpn -> Var qpn -> Bool Source # max :: Var qpn -> Var qpn -> Var qpn Source # min :: Var qpn -> Var qpn -> Var qpn Source #

showVar :: Var QPN -> String Source #

varPN :: Var qpn -> qpn Source #

Extract the package name from a Var

# Conflict sets

data ConflictSet Source #

The set of variables involved in a solver conflict, each paired with details about the conflict.

#### Instances

Instances details

Show ConflictSet Source # |
Instance details Defined in Distribution.Solver.Modular.ConflictSet Methods showsPrec :: Int -> ConflictSet -> ShowS Source # show :: ConflictSet -> String Source # showList :: [ConflictSet] -> ShowS Source #
Eq ConflictSet Source # |
Instance details Defined in Distribution.Solver.Modular.ConflictSet Methods (==) :: ConflictSet -> ConflictSet -> Bool Source # (/=) :: ConflictSet -> ConflictSet -> Bool Source #

type ConflictMap = Map (Var QPN) Int Source #

showConflictSet :: ConflictSet -> String Source #

# Constrained instances

data CI Source #

Constrained instance. It represents the allowed instances for a package, which can be either a fixed instance or a version range.

Constructors

Fixed I |
Constrained VR |

#### Instances

Instances details

Show CI Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods showsPrec :: Int -> CI -> ShowS Source # show :: CI -> String Source # showList :: [CI] -> ShowS Source #
Eq CI Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods (==) :: CI -> CI -> Bool Source # (/=) :: CI -> CI -> Bool Source #

# Flagged dependencies

type FlaggedDeps qpn = [FlaggedDep qpn] Source #

Flagged dependencies

`FlaggedDeps` is the modular solver's view of a packages dependencies: rather than having the dependencies indexed by component, each dependency defines what component it is in.

Note that each dependency is associated with a Component. We must know what component the dependencies belong to, or else we won't be able to construct fine-grained reverse dependencies.

data FlaggedDep qpn Source #

Flagged dependencies can either be plain dependency constraints, or flag-dependent dependency trees.

Constructors

Flagged (FN qpn) FInfo (TrueFlaggedDeps qpn) (FalseFlaggedDeps qpn) | Dependencies which are conditional on a flag choice.
Stanza (SN qpn) (TrueFlaggedDeps qpn) | Dependencies which are conditional on whether or not a stanza (e.g., a test suite or benchmark) is enabled.
Simple (LDep qpn) Component | Dependencies which are always enabled, for the component `comp`.

data LDep qpn Source #

A `Dep` labeled with the reason it was introduced.

`LDep` intentionally has no `Functor` instance because the type variable is used both to record the dependencies as well as who's doing the depending; having a `Functor` instance makes bugs where we don't distinguish these two far too likely. (By rights `LDep` ought to have two type variables.)

Constructors

LDep (DependencyReason qpn) (Dep qpn) |

data Dep qpn Source #

A dependency (constraint) associates a package name with a constrained instance. It can also represent other types of dependencies, such as dependencies on language extensions.

Constructors

Dep (PkgComponent qpn) CI | dependency on a package component
Ext Extension | dependency on a language extension
Lang Language | dependency on a language version
Pkg PkgconfigName PkgconfigVersionRange | dependency on a pkg-config package

#### Instances

Instances details

Functor Dep Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods fmap :: (a -> b) -> Dep a -> Dep b Source # (<$) :: a -> Dep b -> Dep a Source #

data PkgComponent qpn Source #

An exposed component within a package. This type is used to represent build-depends and build-tool-depends dependencies.

Constructors

PkgComponent qpn ExposedComponent |

#### Instances

Instances details

Functor PkgComponent Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods fmap :: (a -> b) -> PkgComponent a -> PkgComponent b Source # (<$) :: a -> PkgComponent b -> PkgComponent a Source #
Show qpn => Show (PkgComponent qpn) Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods showsPrec :: Int -> PkgComponent qpn -> ShowS Source # show :: PkgComponent qpn -> String Source # showList :: [PkgComponent qpn] -> ShowS Source #
Eq qpn => Eq (PkgComponent qpn) Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods (==) :: PkgComponent qpn -> PkgComponent qpn -> Bool Source # (/=) :: PkgComponent qpn -> PkgComponent qpn -> Bool Source #
Ord qpn => Ord (PkgComponent qpn) Source # |

Instance details

Defined in Distribution.Solver.Modular.Dependency

Methods

compare :: PkgComponent qpn -> PkgComponent qpn -> Ordering Source #

(<) :: PkgComponent qpn -> PkgComponent qpn -> Bool Source #

(<=) :: PkgComponent qpn -> PkgComponent qpn -> Bool Source #

(>) :: PkgComponent qpn -> PkgComponent qpn -> Bool Source #

(>=) :: PkgComponent qpn -> PkgComponent qpn -> Bool Source #

max :: PkgComponent qpn -> PkgComponent qpn -> PkgComponent qpn Source #

min :: PkgComponent qpn -> PkgComponent qpn -> PkgComponent qpn Source #

data ExposedComponent Source #

A component that can be depended upon by another package, i.e., a library or an executable.

Constructors

ExposedLib LibraryName |
ExposedExe UnqualComponentName |

#### Instances

Instances details

Show ExposedComponent Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods showsPrec :: Int -> ExposedComponent -> ShowS Source # show :: ExposedComponent -> String Source # showList :: [ExposedComponent] -> ShowS Source #
Eq ExposedComponent Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods (==) :: ExposedComponent -> ExposedComponent -> Bool Source # (/=) :: ExposedComponent -> ExposedComponent -> Bool Source #
Ord ExposedComponent Source # |

Instance details

Defined in Distribution.Solver.Modular.Dependency

Methods

compare :: ExposedComponent -> ExposedComponent -> Ordering Source #

(<) :: ExposedComponent -> ExposedComponent -> Bool Source #

(<=) :: ExposedComponent -> ExposedComponent -> Bool Source #

(>) :: ExposedComponent -> ExposedComponent -> Bool Source #

(>=) :: ExposedComponent -> ExposedComponent -> Bool Source #

max :: ExposedComponent -> ExposedComponent -> ExposedComponent Source #

min :: ExposedComponent -> ExposedComponent -> ExposedComponent Source #

data DependencyReason qpn Source #

The reason that a dependency is active. It identifies the package and any flag and stanza choices that introduced the dependency. It contains everything needed for creating ConflictSets or describing conflicts in solver log messages.

Constructors

DependencyReason qpn (Map Flag FlagValue) (Set Stanza) |

#### Instances

Instances details

Functor DependencyReason Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods fmap :: (a -> b) -> DependencyReason a -> DependencyReason b Source # (<$) :: a -> DependencyReason b -> DependencyReason a Source #
Show qpn => Show (DependencyReason qpn) Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods showsPrec :: Int -> DependencyReason qpn -> ShowS Source # show :: DependencyReason qpn -> String Source # showList :: [DependencyReason qpn] -> ShowS Source #
Eq qpn => Eq (DependencyReason qpn) Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods (==) :: DependencyReason qpn -> DependencyReason qpn -> Bool Source # (/=) :: DependencyReason qpn -> DependencyReason qpn -> Bool Source #

showDependencyReason :: DependencyReason QPN -> String Source #

Print the reason that a dependency was introduced.

flattenFlaggedDeps :: FlaggedDeps qpn -> [(LDep qpn, Component)] Source #

Conservatively flatten out flagged dependencies

NOTE: We do not filter out duplicates.

data QualifyOptions Source #

Options for goal qualification (used in `qualifyDeps`)

See also `defaultQualifyOptions`

Constructors

QO |

Fields

- qoBaseShim :: Bool

  Do we have a version of base relying on another version of base?

- qoSetupIndependent :: Bool

#### Instances

Instances details

Show QualifyOptions Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods showsPrec :: Int -> QualifyOptions -> ShowS Source # show :: QualifyOptions -> String Source # showList :: [QualifyOptions] -> ShowS Source #

qualifyDeps :: QualifyOptions -> QPN -> FlaggedDeps PN -> FlaggedDeps QPN Source #

Apply built-in rules for package qualifiers

Although the behaviour of `qualifyDeps` depends on the `QualifyOptions`, it is important that these `QualifyOptions` are _static_. Qualification does NOT depend on flag assignment; in other words, it behaves the same no matter which choices the solver makes (modulo the global `QualifyOptions`); we rely on this in `linkDeps` (see comment there).

NOTE: It's the _dependencies_ of a package that may or may not be independent from the package itself. Package flag choices must of course be consistent.

unqualifyDeps :: FlaggedDeps QPN -> FlaggedDeps PN Source #

Remove qualifiers from set of dependencies

This is used during link validation: when we link package `Q.A` to `Q'.A`, then all dependencies `Q.B` need to be linked to `Q'.B`. In order to compute what to link these dependencies to, we need to requalify `Q.B` to become `Q'.B`; we do this by first removing all qualifiers and then calling `qualifyDeps` again.

# Reverse dependency map

type RevDepMap = Map QPN [(Component, QPN)] Source #

A map containing reverse dependencies between qualified package names.

# Goals

data Goal qpn Source #

A goal is just a solver variable paired with a reason. The reason is only used for tracing.

Constructors

Goal (Var qpn) (GoalReason qpn) |

#### Instances

Instances details

Functor Goal Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods fmap :: (a -> b) -> Goal a -> Goal b Source # (<$) :: a -> Goal b -> Goal a Source #
Show qpn => Show (Goal qpn) Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods showsPrec :: Int -> Goal qpn -> ShowS Source # show :: Goal qpn -> String Source # showList :: [Goal qpn] -> ShowS Source #
Eq qpn => Eq (Goal qpn) Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods (==) :: Goal qpn -> Goal qpn -> Bool Source # (/=) :: Goal qpn -> Goal qpn -> Bool Source #

data GoalReason qpn Source #

Reason why a goal is being added to a goal set.

Constructors

UserGoal |
DependencyGoal (DependencyReason qpn) |

#### Instances

Instances details

Functor GoalReason Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods fmap :: (a -> b) -> GoalReason a -> GoalReason b Source # (<$) :: a -> GoalReason b -> GoalReason a Source #
Show qpn => Show (GoalReason qpn) Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods showsPrec :: Int -> GoalReason qpn -> ShowS Source # show :: GoalReason qpn -> String Source # showList :: [GoalReason qpn] -> ShowS Source #
Eq qpn => Eq (GoalReason qpn) Source # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods (==) :: GoalReason qpn -> GoalReason qpn -> Bool Source # (/=) :: GoalReason qpn -> GoalReason qpn -> Bool Source #

type QGoalReason = GoalReason QPN Source #

goalToVar :: Goal a -> Var a Source #

varToConflictSet :: Var QPN -> ConflictSet Source #

Compute a singleton conflict set from a `Var`

goalReasonToConflictSet :: GoalReason QPN -> ConflictSet Source #

Convert a `GoalReason` to a `ConflictSet` that can be used when the goal leads to a conflict.

goalReasonToConflictSetWithConflict :: QPN -> GoalReason QPN -> ConflictSet Source #

Convert a `GoalReason` to a `ConflictSet` containing the reason that the conflict occurred, namely the conflict set variables caused a conflict by introducing the given package goal. See the documentation for `GoalConflict`.

This function currently only specifies the reason for the conflict in the simple case where the `GoalReason` does not involve any flags or stanzas. Otherwise, it falls back to calling `goalReasonToConflictSet`.

dependencyReasonToConflictSet :: DependencyReason QPN -> ConflictSet Source #

This function returns the solver variables responsible for the dependency. It drops the values chosen for flag and stanza variables, which are only needed for log messages.

dependencyReasonToConflictSetWithVersionConstraintConflict :: QPN -> Ver -> DependencyReason QPN -> ConflictSet Source #

Convert a `DependencyReason` to a `ConflictSet` specifying that the conflict occurred because the conflict set variables introduced a problematic version constraint. See the documentation for `VersionConstraintConflict`.

This function currently only specifies the reason for the conflict in the simple case where the `DependencyReason` does not involve any flags or stanzas. Otherwise, it falls back to calling `dependencyReasonToConflictSet`.

dependencyReasonToConflictSetWithVersionConflict :: QPN -> OrderedVersionRange -> DependencyReason QPN -> ConflictSet Source #

Convert a `DependencyReason` to a `ConflictSet` specifying that the conflict occurred because the conflict set variables introduced a version of a package that was excluded by a version constraint. See the documentation for `VersionConflict`.

This function currently only specifies the reason for the conflict in the simple case where the `DependencyReason` does not involve any flags or stanzas. Otherwise, it falls back to calling `dependencyReasonToConflictSet`.