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

Summary of exported operations:

emptySet :: LookupSet  Deterministic 
The empty lookup set.
setLocallyIgnored :: LookupSet -> [String] -> LookupSet  Deterministic 
Set the set of packages whose locally installed versions are ignored when finding all package versions.
addPackages :: LookupSet -> [Package] -> LookupSource -> LookupSet  Deterministic 
Adds multiple packages to a lookup set with the same source.
allPackages :: LookupSet -> [Package]  Deterministic 
addPackage :: LookupSet -> Package -> LookupSource -> LookupSet  Deterministic 
Adds a package to a lookup set.
findAllVersions :: LookupSet -> String -> Bool -> [Package]  Deterministic 
Finds all versions of a package known to the lookup set.
lookupSource :: LookupSet -> Package -> Maybe LookupSource  Deterministic 
Finds the source for a package in the lookup set
findLatestVersion :: LookupSet -> String -> Bool -> Maybe Package  Deterministic 
Finds the latest version of a package known to the lookup set.
findVersion :: LookupSet -> String -> (Int,Int,Int,Maybe String) -> Maybe Package  Deterministic 
Finds a specific version of a package in the lookup set.

Exported datatypes:


LookupSource

Constructors:

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

LookupSet

Constructors:


Exported operations:

emptySet :: LookupSet  Deterministic 

The empty lookup set.

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.

Example call:
(addPackages l p s)
Parameters:
  • l : the set to add to
  • p : the packages to add
  • s : where are the package specs from?

allPackages :: LookupSet -> [Package]  Deterministic 

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

Adds a package to a lookup set.

Example call:
(addPackage l p s)
Parameters:
  • l : the set to add to
  • p : the package to add
  • s : where is the package spec from?

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.

Example call:
(findAllVersions l p pre)
Parameters:
  • l : the lookup set
  • p : the name of the package to search for
  • pre : should pre-release versions be included?
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

Example call:
(lookupSource ls p)
Parameters:
  • ls : the lookup set
  • p : the package to search for

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

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

Example call:
(findLatestVersion l p pre)
Parameters:
  • l : the lookup set
  • p : the name of the package to search for
  • pre : should pre-release versions be included?

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

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

Example call:
(findVersion l p v)
Parameters:
  • l : the lookup set
  • p : the name of the package
  • v : the package version