Distribution.Solver.Modular.Dependency

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 #

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

showVar :: Var QPN -> String #

varPN :: Var qpn -> qpn #

Extract the package name from a Var

# Conflict sets

data ConflictSet #

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

#### Instances

Instances details

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

type ConflictMap = Map (Var QPN) Int #

showConflictSet :: ConflictSet -> String #

# Constrained instances

data CI #

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

# Flagged dependencies

type FlaggedDeps qpn = [FlaggedDep qpn] #

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 #

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 #

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 #

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 # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods fmap :: (a -> b) -> Dep a -> Dep b # (<$) :: a -> Dep b -> Dep a #

data PkgComponent qpn #

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

data ExposedComponent #

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 # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods showsPrec :: Int -> ExposedComponent -> ShowS # show :: ExposedComponent -> String # showList :: [ExposedComponent] -> ShowS #
Eq ExposedComponent # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods (==) :: ExposedComponent -> ExposedComponent -> Bool # (/=) :: ExposedComponent -> ExposedComponent -> Bool #
Ord ExposedComponent # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods compare :: ExposedComponent -> ExposedComponent -> Ordering # (<) :: ExposedComponent -> ExposedComponent -> Bool # (<=) :: ExposedComponent -> ExposedComponent -> Bool # (>) :: ExposedComponent -> ExposedComponent -> Bool # (>=) :: ExposedComponent -> ExposedComponent -> Bool # max :: ExposedComponent -> ExposedComponent -> ExposedComponent # min :: ExposedComponent -> ExposedComponent -> ExposedComponent #

data DependencyReason qpn #

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

showDependencyReason :: DependencyReason QPN -> String #

Print the reason that a dependency was introduced.

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

Conservatively flatten out flagged dependencies

NOTE: We do not filter out duplicates.

data QualifyOptions #

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 # |
Instance details Defined in Distribution.Solver.Modular.Dependency Methods showsPrec :: Int -> QualifyOptions -> ShowS # show :: QualifyOptions -> String # showList :: [QualifyOptions] -> ShowS #

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

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 #

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)] #

A map containing reverse dependencies between qualified package names.

# Goals

data Goal qpn #

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

data GoalReason qpn #

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

Constructors

UserGoal |
DependencyGoal (DependencyReason qpn) |

#### Instances

Instances details

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

type QGoalReason = GoalReason QPN #

goalToVar :: Goal a -> Var a #

varToConflictSet :: Var QPN -> ConflictSet #

Compute a singleton conflict set from a `Var`

goalReasonToConflictSet :: GoalReason QPN -> ConflictSet #

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

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

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 #

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 #

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 #

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`.