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 Source #

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 Source # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods fmap :: (a -> b) -> PackageIndex a -> PackageIndex b Source # (<$) :: a -> PackageIndex b -> PackageIndex a Source #
Binary pkg => Binary (PackageIndex pkg) Source # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods put :: PackageIndex pkg -> Put Source # get :: Get (PackageIndex pkg) Source # putList :: [PackageIndex pkg] -> Put Source #
Package pkg => Monoid (PackageIndex pkg) Source # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods mempty :: PackageIndex pkg Source # mappend :: PackageIndex pkg -> PackageIndex pkg -> PackageIndex pkg Source # mconcat :: [PackageIndex pkg] -> PackageIndex pkg Source #
Package pkg => Semigroup (PackageIndex pkg) Source # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods (<>) :: PackageIndex pkg -> PackageIndex pkg -> PackageIndex pkg Source # sconcat :: NonEmpty (PackageIndex pkg) -> PackageIndex pkg Source # stimes :: Integral b => b -> PackageIndex pkg -> PackageIndex pkg Source #
Generic (PackageIndex pkg) Source # |

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-5dSETZK2idVHohhzkfJS3u" '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 Source #

to :: Rep (PackageIndex pkg) x -> PackageIndex pkg Source #

Read pkg => Read (PackageIndex pkg) Source # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods readsPrec :: Int -> ReadS (PackageIndex pkg) Source # readList :: ReadS [PackageIndex pkg] Source # readPrec :: ReadPrec (PackageIndex pkg) Source # readListPrec :: ReadPrec [PackageIndex pkg] Source #
Show pkg => Show (PackageIndex pkg) Source # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods showsPrec :: Int -> PackageIndex pkg -> ShowS Source # show :: PackageIndex pkg -> String Source # showList :: [PackageIndex pkg] -> ShowS Source #
Eq pkg => Eq (PackageIndex pkg) Source # |
Instance details Defined in Distribution.Solver.Types.PackageIndex Methods (==) :: PackageIndex pkg -> PackageIndex pkg -> Bool Source # (/=) :: PackageIndex pkg -> PackageIndex pkg -> Bool Source #
type Rep (PackageIndex pkg) Source # |

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-5dSETZK2idVHohhzkfJS3u" '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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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

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

Removes a single package from the index.

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

Removes all packages satisfying this dependency from the index.

# Queries

## Precise lookups

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

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

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

Does a case-sensitive search by package name.

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

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

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

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 Source #

Constructors

None |
Unambiguous a |
Ambiguous [a] |

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

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

## Bulk queries

allPackages :: PackageIndex pkg -> [pkg] Source #

Get all the packages from the index.

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

Get all the packages from the index.

They are grouped by package name, case-sensitively.