PubGrub.Internal.Memory

A Memory acts like a structured partial solution where terms are regrouped by package in a dictionary. This module provides functions to manage it.

type alias Memory =
Dict String PackageAssignments

Memory is the set of all assignments previous to (including) its paired assignment in the partial solution list.

Those previous assignments are regrouped by package, making it easier to find out if a decision was made for a given package, and to list all corresponding derivations of a package.

Contrary to PartialSolution, Memory does not store derivations causes, only the terms.

type alias PackageAssignments =
{ decision : Maybe Version
, derivations : List Term
}

A package memory contains the potential decision and derivations that have already been made for a given package.

Building a Memory

fromDecision : String -> Version -> Memory

Initialize a Memory from a decision.

fromDerivation : String -> Term -> Memory

Initialize a Memory from a derivation.

addAssignment : Assignment -> Memory -> Memory

Building step of a Memory from a given assignment.

addDecision : String -> Version -> Memory -> Memory

Add a decision to a Memory.

addDerivation : String -> Term -> Memory -> Memory

Add a derivation to a Memory.

Retrieving terms in a Memory

terms : Memory -> Dict String (List Term)

Retrieve all terms in memory.

Finding a solution

potentialPackages : Memory -> Dict String (List Term)

Extract all packages that may potentially be picked next to continue solving package dependencies. A package is a potential pick if there isn't an already version selected (no "decision") and if it contains at least one positive derivation term in the partial solution.

solution : Memory -> Maybe (List ( String, Version ))

If a partial solution has, for every positive derivation, a corresponding decision that satisfies that assignment, it's a total solution and version solving has succeeded.