Module CPM.LookupSet

This module implements the LookupSet datatype. A lookup set is used to store and query packages for dependency resolution. It stores the source of a package specification alongside the specification itself (e.g. the global repository or the local package cache).

Exported Datatypes


data LookupSource

Constructors:

  • FromRepository :: LookupSource
  • FromLocalCache :: LookupSource
  • FromGlobalCache :: LookupSource

data LookupSet

Exported Functions


emptySet :: LookupSet  Deterministic 

The empty lookup set.

Further infos:
  • solution complete, i.e., able to compute all solutions

setLocallyIgnored :: LookupSet -> [String] -> LookupSet  Deterministic 

Set the set of packages whose locally installed versions are ignored when finding all package versions.

Further infos:
  • solution complete, i.e., able to compute all solutions

addPackages :: LookupSet -> [Package] -> LookupSource -> LookupSet  Deterministic 

Adds multiple packages to a lookup set with the same source.

:: LookupSet  the set to add to
-> [Package]  the packages to add
-> LookupSource  where are the package specs from?
-> LookupSet 

allPackages :: LookupSet -> [Package]  Deterministic 


addPackage :: LookupSet -> Package -> LookupSource -> LookupSet  Deterministic 

Adds a package to a lookup set.

:: LookupSet  the set to add to
-> Package  the package to add
-> LookupSource  where is the package spec from?
-> LookupSet 

findAllVersions :: LookupSet -> String -> Bool -> [Package]  Deterministic 

Finds all versions of a package known to the lookup set. Returns the packages from the local cache first, and then from other sources. Each group is sorted from newest do oldest version.

:: LookupSet  the lookup set
-> String  the name of the package to search for
-> Bool  should pre-release versions be included?
-> [Package] 
Properties:
findAllVersions ls "A" False -=- [aLocal,aNonLocal] where aLocal = cPackage "A" (1,0,0,Nothing) [] aNonLocal = cPackage "A" (1,1,0,Nothing) [] ls = addPackage (addPackage emptySet aLocal FromLocalCache) aNonLocal FromRepository(test_findAllVersions_localBeforeNonLocal)
findAllVersions ls "A" False -=- [aNonLocal] where aLocal = cPackage "A" (1,0,0,Nothing) [] aNonLocal = cPackage "A" (1,1,0,Nothing) [] ls = setLocallyIgnored (addPackage (addPackage emptySet aLocal FromLocalCache) aNonLocal FromRepository) ["A"](test_findAllVersions_nonLocalIfIgnored)

lookupSource :: LookupSet -> Package -> Maybe LookupSource  Deterministic 

Finds the source for a package in the lookup set

:: LookupSet  the lookup set
-> Package  the package to search for
-> Maybe LookupSource 

findLatestVersion :: LookupSet -> String -> Bool -> Maybe Package  Deterministic 

Finds the latest version of a package known to the lookup set.

:: LookupSet  the lookup set
-> String  the name of the package to search for
-> Bool  should pre-release versions be included?
-> Maybe Package 

findVersion :: LookupSet -> String -> (Int, Int, Int, Maybe String) -> Maybe Package  Deterministic 

Finds a specific version of a package in the lookup set.

:: LookupSet  the lookup set
-> String  the name of the package
-> Version  the package version
-> Maybe Package