Distribution.Solver.Types.PackageIndex

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

Copyright | (c) David Himmelstrup 2005 Bjorn Bringert 2007 Duncan Coutts 2008
Maintainer | cabal-devel@haskell.org
Portability | portable
Safe Haskell | None
Language | Haskell2010

Distribution.Solver.Types.PackageIndex

Contents

- Package index data type
- Creating an index
- Updates
- Queries
  - Precise lookups
  - Case-insensitive searches
  - Bulk queries

Description

An index of packages.

Synopsis

- data PackageIndex pkg
- fromList :: Package pkg => [pkg] -> PackageIndex pkg
- merge :: Package pkg => PackageIndex pkg -> PackageIndex pkg -> PackageIndex pkg
- override :: Package pkg => PackageIndex pkg -> PackageIndex pkg -> PackageIndex pkg
- insert :: Package pkg => pkg -> PackageIndex pkg -> PackageIndex pkg
- deletePackageName :: Package pkg => PackageName -> PackageIndex pkg -> PackageIndex pkg
- deletePackageId :: Package pkg => PackageIdentifier -> PackageIndex pkg -> PackageIndex pkg
- deleteDependency :: Package pkg => PackageName -> VersionRange -> PackageIndex pkg -> PackageIndex pkg
- elemByPackageId :: Package pkg => PackageIndex pkg -> PackageIdentifier -> Bool
- elemByPackageName :: Package pkg => PackageIndex pkg -> PackageName -> Bool
- lookupPackageName :: Package pkg => PackageIndex pkg -> PackageName -> [pkg]
- lookupPackageId :: Package pkg => PackageIndex pkg -> PackageIdentifier -> Maybe pkg
- lookupDependency :: Package pkg => PackageIndex pkg -> PackageName -> VersionRange -> [pkg]
- searchByName :: PackageIndex pkg -> String -> [(PackageName, [pkg])]
- data SearchResult a
  - = None
  - | Unambiguous a
  - | Ambiguous [a]
- searchByNameSubstring :: PackageIndex pkg -> String -> [(PackageName, [pkg])]
- searchWithPredicate :: PackageIndex pkg -> (String -> Bool) -> [(PackageName, [pkg])]
- allPackages :: PackageIndex pkg -> [pkg]
- allPackagesByName :: PackageIndex pkg -> [[pkg]]

# Package index data type

data PackageIndex pkg #

The collection of information about packages from one or more `PackageDB`s.

It can be searched efficiently by package name and version.

#### Instances

Instances details

Functor PackageIndex # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods fmap :: (a -> b) -> PackageIndex a -> PackageIndex b # (<$) :: a -> PackageIndex b -> PackageIndex a #
Binary pkg => Binary (PackageIndex pkg) # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods put :: PackageIndex pkg -> Put # get :: Get (PackageIndex pkg) # putList :: [PackageIndex pkg] -> Put #
Package pkg => Monoid (PackageIndex pkg) # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods mempty :: PackageIndex pkg # mappend :: PackageIndex pkg -> PackageIndex pkg -> PackageIndex pkg # mconcat :: [PackageIndex pkg] -> PackageIndex pkg #
Package pkg => Semigroup (PackageIndex pkg) # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods (<>) :: PackageIndex pkg -> PackageIndex pkg -> PackageIndex pkg # sconcat :: NonEmpty (PackageIndex pkg) -> PackageIndex pkg # stimes :: Integral b => b -> PackageIndex pkg -> PackageIndex pkg #
Generic (PackageIndex pkg) # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Associated Types
type Rep (PackageIndex pkg) |
Instance details Defined in Distribution.Solver.Types.PackageIndex type Rep (PackageIndex pkg) = D1 ('MetaData "PackageIndex" "Distribution.Solver.Types.PackageIndex" "cabal-install-solver-3.12.1.0-BcLJX5rVQuejx1qrKAH5j" 'True) (C1 ('MetaCons "PackageIndex" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map PackageName [pkg]))))
Methods from :: PackageIndex pkg -> Rep (PackageIndex pkg) x # to :: Rep (PackageIndex pkg) x -> PackageIndex pkg #
Read pkg => Read (PackageIndex pkg) # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods readsPrec :: Int -> ReadS (PackageIndex pkg) # readList :: ReadS [PackageIndex pkg] # readPrec :: ReadPrec (PackageIndex pkg) # readListPrec :: ReadPrec [PackageIndex pkg] #
Show pkg => Show (PackageIndex pkg) # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods showsPrec :: Int -> PackageIndex pkg -> ShowS # show :: PackageIndex pkg -> String # showList :: [PackageIndex pkg] -> ShowS #
Eq pkg => Eq (PackageIndex pkg) # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods (==) :: PackageIndex pkg -> PackageIndex pkg -> Bool # (/=) :: PackageIndex pkg -> PackageIndex pkg -> Bool #
type Rep (PackageIndex pkg) # |
Instance details Defined in Distribution.Solver.Types.PackageIndex type Rep (PackageIndex pkg) = D1 ('MetaData "PackageIndex" "Distribution.Solver.Types.PackageIndex" "cabal-install-solver-3.12.1.0-BcLJX5rVQuejx1qrKAH5j" 'True) (C1 ('MetaCons "PackageIndex" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map PackageName [pkg]))))

# Creating an index

fromList :: Package pkg => [pkg] -> PackageIndex pkg #

Build an index out of a bunch of packages.

If there are duplicates, later ones mask earlier ones.

# Updates

merge :: Package pkg => PackageIndex pkg -> PackageIndex pkg -> PackageIndex pkg #

Merge two indexes.

Packages from the second mask packages of the same exact name (case-sensitively) from the first.

override :: Package pkg => PackageIndex pkg -> PackageIndex pkg -> PackageIndex pkg #

Override-merge of two indexes.

Packages from the second mask packages of the same exact name (case-sensitively) from the first.

insert :: Package pkg => pkg -> PackageIndex pkg -> PackageIndex pkg #

Inserts a single package into the index.

This is equivalent to (but slightly quicker than) using `mappend` or `merge` with a singleton index.

deletePackageName :: Package pkg => PackageName -> PackageIndex pkg -> PackageIndex pkg #

Removes all packages with this (case-sensitive) name from the index.

deletePackageId :: Package pkg => PackageIdentifier -> PackageIndex pkg -> PackageIndex pkg #

Removes a single package from the index.

deleteDependency :: Package pkg => PackageName -> VersionRange -> PackageIndex pkg -> PackageIndex pkg #

Removes all packages satisfying this dependency from the index.

# Queries

## Precise lookups

elemByPackageId :: Package pkg => PackageIndex pkg -> PackageIdentifier -> Bool #

elemByPackageName :: Package pkg => PackageIndex pkg -> PackageName -> Bool #

lookupPackageName :: Package pkg => PackageIndex pkg -> PackageName -> [pkg] #

Does a case-sensitive search by package name.

lookupPackageId :: Package pkg => PackageIndex pkg -> PackageIdentifier -> Maybe pkg #

Does a lookup by package id (name & version).

Since multiple package DBs mask each other case-sensitively by package name, then we get back at most one package.

lookupDependency :: Package pkg => PackageIndex pkg -> PackageName -> VersionRange -> [pkg] #

Does a case-sensitive search by package name and a range of versions.

We get back any number of versions of the specified package name, all satisfying the version range constraint.

## Case-insensitive searches

searchByName :: PackageIndex pkg -> String -> [(PackageName, [pkg])] #

Does a case-insensitive search by package name.

If there is only one package that compares case-insensitively to this name then the search is unambiguous and we get back all versions of that package. If several match case-insensitively but one matches exactly then it is also unambiguous.

If however several match case-insensitively and none match exactly then we have an ambiguous result, and we get back all the versions of all the packages. The list of ambiguous results is split by exact package name. So it is a non-empty list of non-empty lists.

data SearchResult a #

Constructors

None |
Unambiguous a |
Ambiguous [a] |

searchByNameSubstring :: PackageIndex pkg -> String -> [(PackageName, [pkg])] #

Does a case-insensitive substring search by package name.

That is, all packages that contain the given string in their name.

searchWithPredicate :: PackageIndex pkg -> (String -> Bool) -> [(PackageName, [pkg])] #

## Bulk queries

allPackages :: PackageIndex pkg -> [pkg] #

Get all the packages from the index.

allPackagesByName :: PackageIndex pkg -> [[pkg]] #

Get all the packages from the index.

They are grouped by package name, case-sensitively.