Portability | portable |
---|---|
Maintainer | cabal-devel@haskell.org |
Safe Haskell | Safe-Inferred |
Defines a package identifier along with a parser and pretty printer for it.
PackageIdentifier
s consist of a name and an exact version. It also defines
a Dependency
data type. A dependency is a package name and a version
range, like "foo >= 1.2 && < 2"
.
- newtype PackageName = PackageName {
- unPackageName :: String
- data PackageIdentifier = PackageIdentifier {}
- type PackageId = PackageIdentifier
- newtype InstalledPackageId = InstalledPackageId String
- data PackageKey
- = PackageKey !String !Word64 !Word64
- | OldPackageKey !PackageId
- mkPackageKey :: Bool -> PackageId -> [PackageKey] -> [(ModuleName, (PackageKey, ModuleName))] -> PackageKey
- packageKeyHash :: PackageKey -> String
- packageKeyLibraryName :: PackageId -> PackageKey -> String
- data Dependency = Dependency PackageName VersionRange
- thisPackageVersion :: PackageIdentifier -> Dependency
- notThisPackageVersion :: PackageIdentifier -> Dependency
- simplifyDependency :: Dependency -> Dependency
- class Package pkg where
- packageId :: pkg -> PackageIdentifier
- packageName :: Package pkg => pkg -> PackageName
- packageVersion :: Package pkg => pkg -> Version
- class Package pkg => PackageFixedDeps pkg where
- depends :: pkg -> [PackageIdentifier]
- class Package pkg => PackageInstalled pkg where
- installedPackageId :: pkg -> InstalledPackageId
- installedDepends :: pkg -> [InstalledPackageId]
Package ids
newtype PackageName
PackageName | |
|
Eq PackageName | |
Data PackageName | |
Ord PackageName | |
Read PackageName | |
Show PackageName | |
Typeable PackageName | |
Generic PackageName | |
NFData PackageName | |
Text PackageName |
data PackageIdentifier
The name and version of a package.
PackageIdentifier | |
|
Eq PackageIdentifier | |
Data PackageIdentifier | |
Ord PackageIdentifier | |
Read PackageIdentifier | |
Show PackageIdentifier | |
Typeable PackageIdentifier | |
Generic PackageIdentifier | |
NFData PackageIdentifier | |
Text PackageIdentifier | |
Package PackageIdentifier |
type PackageId = PackageIdentifier
Type alias so we can use the shorter name PackageId.
Installed package identifiers
newtype InstalledPackageId
An InstalledPackageId uniquely identifies an instance of an installed
package. There can be at most one package with a given InstalledPackageId
in a package database, or overlay of databases.
InstalledPackageId String |
Eq InstalledPackageId | |
Data InstalledPackageId | |
Ord InstalledPackageId | |
Read InstalledPackageId | |
Show InstalledPackageId | |
Typeable InstalledPackageId | |
Generic InstalledPackageId | |
Text InstalledPackageId |
Package keys (used for linker symbols and library name)
data PackageKey
PackageKey !String !Word64 !Word64 | Modern package key which is a hash of the PackageId and the transitive dependency key. Manually inline it here so we can get the instances we need. Also contains a short informative string |
OldPackageKey !PackageId | Old-style package key which is just a |
Eq PackageKey | |
Data PackageKey | |
Ord PackageKey | |
Read PackageKey | |
Show PackageKey | |
Typeable PackageKey | |
Generic PackageKey | |
NFData PackageKey | |
Text PackageKey |
mkPackageKey :: Bool -> PackageId -> [PackageKey] -> [(ModuleName, (PackageKey, ModuleName))] -> PackageKey
Generates a PackageKey
from a PackageId
, sorted package keys of the
immediate dependencies.
packageKeyHash :: PackageKey -> String
packageKeyLibraryName :: PackageId -> PackageKey -> String
Package source dependencies
data Dependency
Describes a dependency on a source package (API)
Eq Dependency | |
Data Dependency | |
Read Dependency | |
Show Dependency | |
Typeable Dependency | |
Generic Dependency | |
Text Dependency |
simplifyDependency :: Dependency -> Dependency
Simplify the VersionRange
expression in a Dependency
.
See simplifyVersionRange
.
Package classes
class Package pkg where
Class of things that have a PackageIdentifier
Types in this class are all notions of a package. This allows us to have different types for the different phases that packages go though, from simple name/id, package description, configured or installed packages.
Not all kinds of packages can be uniquely identified by a
PackageIdentifier
. In particular, installed packages cannot, there may be
many installed instances of the same source package.
packageId :: pkg -> PackageIdentifier
packageName :: Package pkg => pkg -> PackageName
packageVersion :: Package pkg => pkg -> Version
class Package pkg => PackageFixedDeps pkg where
Subclass of packages that have specific versioned dependencies.
So for example a not-yet-configured package has dependencies on version ranges, not specific versions. A configured or an already installed package depends on exact versions. Some operations or data structures (like dependency graphs) only make sense on this subclass of package types.
depends :: pkg -> [PackageIdentifier]
class Package pkg => PackageInstalled pkg where
Class of installed packages.
The primary data type which is an instance of this package is
InstalledPackageInfo
, but when we are doing install plans in Cabal install
we may have other, installed package-like things which contain more metadata.
Installed packages have exact dependencies installedDepends
.
installedPackageId :: pkg -> InstalledPackageId
installedDepends :: pkg -> [InstalledPackageId]