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

Copyright | (c) Duncan Coutts 2011
License | BSD-like
Maintainer | duncan@community.haskell.org
Safe Haskell | None
Language | Haskell2010

Distribution.Client.Targets

Contents

- User targets
- Resolving user targets to package specifiers
  - Detailed interface
- User constraints

Description

Handling for user-specified targets

Synopsis

- data UserTarget
  - = UserTargetNamed PackageVersionConstraint
  - | UserTargetLocalDir FilePath
  - | UserTargetLocalCabalFile FilePath
  - | UserTargetLocalTarball FilePath
  - | UserTargetRemoteTarball URI
- readUserTargets :: Verbosity -> [String] -> IO [UserTarget]
- resolveUserTargets :: Package pkg => Verbosity -> RepoContext -> PackageIndex pkg -> [UserTarget] -> IO [PackageSpecifier UnresolvedSourcePackage]
- data UserTargetProblem
  - = UserTargetUnexpectedFile String
  - | UserTargetNonexistantFile String
  - | UserTargetUnexpectedUriScheme String
  - | UserTargetUnrecognisedUri String
  - | UserTargetUnrecognised String
- readUserTarget :: String -> IO (Either UserTargetProblem UserTarget)
- reportUserTargetProblems :: Verbosity -> [UserTargetProblem] -> IO ()
- expandUserTarget :: Verbosity -> UserTarget -> IO [PackageTarget (PackageLocation ())]
- data PackageTarget pkg
  - = PackageTargetNamed PackageName [PackageProperty] UserTarget
  - | PackageTargetNamedFuzzy PackageName [PackageProperty] UserTarget
  - | PackageTargetLocation pkg
- fetchPackageTarget :: Verbosity -> RepoContext -> PackageTarget (PackageLocation ()) -> IO (PackageTarget ResolvedPkgLoc)
- readPackageTarget :: Verbosity -> PackageTarget ResolvedPkgLoc -> IO (PackageTarget UnresolvedSourcePackage)
- data PackageTargetProblem
  - = PackageNameUnknown PackageName UserTarget
  - | PackageNameAmbiguous PackageName [PackageName] UserTarget
- reportPackageTargetProblems :: Verbosity -> [PackageTargetProblem] -> IO ()
- disambiguatePackageTargets :: Package pkg' => PackageIndex pkg' -> [PackageName] -> [PackageTarget pkg] -> ([PackageTargetProblem], [PackageSpecifier pkg])
- disambiguatePackageName :: PackageNameEnv -> PackageName -> MaybeAmbiguous PackageName
- data UserQualifier
  - = UserQualToplevel
  - | UserQualSetup PackageName
  - | UserQualExe PackageName PackageName
- data UserConstraintScope
  - = UserQualified UserQualifier PackageName
  - | UserAnySetupQualifier PackageName
  - | UserAnyQualifier PackageName
- data UserConstraint = UserConstraint UserConstraintScope PackageProperty
- userConstraintPackageName :: UserConstraint -> PackageName
- readUserConstraint :: String -> Either String UserConstraint
- userToPackageConstraint :: UserConstraint -> PackageConstraint

# User targets

data UserTarget #

Various ways that a user may specify a package or package collection.

Constructors

UserTargetNamed PackageVersionConstraint

A partially specified package, identified by name and possibly with an exact version or a version constraint.

    cabal install foo
    cabal install foo-1.0
    cabal install 'foo < 2'

UserTargetLocalDir FilePath

A specific package that is unpacked in a local directory, often the current directory.

    cabal install .
    cabal install ../lib/other

- Note: in future, if multiple `.cabal` files are allowed in a single directory then this will refer to the collection of packages.

UserTargetLocalCabalFile FilePath

A specific local unpacked package, identified by its `.cabal` file.

    cabal install foo.cabal
    cabal install ../lib/other/bar.cabal

UserTargetLocalTarball FilePath

A specific package that is available as a local tarball file

    cabal install dist/foo-1.0.tar.gz
    cabal install ../build/baz-1.0.tar.gz

UserTargetRemoteTarball URI

A specific package that is available as a remote tarball file

    cabal install http://code.haskell.org/~user/foo/foo-0.9.tar.gz

#### Instances

Instances details

Show UserTarget # |
Instance details Defined in Distribution.Client.Targets Methods showsPrec :: Int -> UserTarget -> ShowS # show :: UserTarget -> String # showList :: [UserTarget] -> ShowS #
Eq UserTarget # |
Instance details Defined in Distribution.Client.Targets Methods (==) :: UserTarget -> UserTarget -> Bool # (/=) :: UserTarget -> UserTarget -> Bool #

readUserTargets :: Verbosity -> [String] -> IO [UserTarget] #

# Resolving user targets to package specifiers

resolveUserTargets :: Package pkg => Verbosity -> RepoContext -> PackageIndex pkg -> [UserTarget] -> IO [PackageSpecifier UnresolvedSourcePackage] #

Given a bunch of user-specified targets, try to resolve what it is they refer to. They can either be specific packages (local dirs, tarballs etc) or they can be named packages (with or without version info).

## Detailed interface

data UserTargetProblem #

Constructors

UserTargetUnexpectedFile String |
UserTargetNonexistantFile String |
UserTargetUnexpectedUriScheme String |
UserTargetUnrecognisedUri String |
UserTargetUnrecognised String |

#### Instances

Instances details

Show UserTargetProblem # |
Instance details Defined in Distribution.Client.Targets Methods showsPrec :: Int -> UserTargetProblem -> ShowS # show :: UserTargetProblem -> String # showList :: [UserTargetProblem] -> ShowS #

readUserTarget :: String -> IO (Either UserTargetProblem UserTarget) #

reportUserTargetProblems :: Verbosity -> [UserTargetProblem] -> IO () #

expandUserTarget :: Verbosity -> UserTarget -> IO [PackageTarget (PackageLocation ())] #

Given a user-specified target, expand it to a bunch of package targets (each of which refers to only one package).

data PackageTarget pkg #

An intermediate between a `UserTarget` and a resolved `PackageSpecifier`. Unlike a `UserTarget`, a `PackageTarget` refers only to a single package.

Constructors

PackageTargetNamed PackageName [PackageProperty] UserTarget |
PackageTargetNamedFuzzy PackageName [PackageProperty] UserTarget | A package identified by name, but case insensitively, so it needs to be resolved to the right case-sensitive name.
PackageTargetLocation pkg |

#### Instances

Instances details

Functor PackageTarget # |
Instance details Defined in Distribution.Client.Targets Methods fmap :: (a -> b) -> PackageTarget a -> PackageTarget b # (<$) :: a -> PackageTarget b -> PackageTarget a #
Foldable PackageTarget # |

Instance details

Defined in Distribution.Client.Targets

Methods

fold :: Monoid m => PackageTarget m -> m #

foldMap :: Monoid m => (a -> m) -> PackageTarget a -> m #

foldMap' :: Monoid m => (a -> m) -> PackageTarget a -> m #

foldr :: (a -> b -> b) -> b -> PackageTarget a -> b #

foldr' :: (a -> b -> b) -> b -> PackageTarget a -> b #

foldl :: (b -> a -> b) -> b -> PackageTarget a -> b #

foldl' :: (b -> a -> b) -> b -> PackageTarget a -> b #

foldr1 :: (a -> a -> a) -> PackageTarget a -> a #

foldl1 :: (a -> a -> a) -> PackageTarget a -> a #

toList :: PackageTarget a -> [a] #

null :: PackageTarget a -> Bool #

length :: PackageTarget a -> Int #

elem :: Eq a => a -> PackageTarget a -> Bool #

maximum :: Ord a => PackageTarget a -> a #

minimum :: Ord a => PackageTarget a -> a #

sum :: Num a => PackageTarget a -> a #

product :: Num a => PackageTarget a -> a #

Traversable PackageTarget # |
Instance details Defined in Distribution.Client.Targets Methods traverse :: Applicative f => (a -> f b) -> PackageTarget a -> f (PackageTarget b) # sequenceA :: Applicative f => PackageTarget (f a) -> f (PackageTarget a) # mapM :: Monad m => (a -> m b) -> PackageTarget a -> m (PackageTarget b) # sequence :: Monad m => PackageTarget (m a) -> m (PackageTarget a) #
Show pkg => Show (PackageTarget pkg) # |
Instance details Defined in Distribution.Client.Targets Methods showsPrec :: Int -> PackageTarget pkg -> ShowS # show :: PackageTarget pkg -> String # showList :: [PackageTarget pkg] -> ShowS #

fetchPackageTarget :: Verbosity -> RepoContext -> PackageTarget (PackageLocation ()) -> IO (PackageTarget ResolvedPkgLoc) #

Fetch any remote targets so that they can be read.

readPackageTarget :: Verbosity -> PackageTarget ResolvedPkgLoc -> IO (PackageTarget UnresolvedSourcePackage) #

Given a package target that has been fetched, read the .cabal file.

This only affects targets given by location, named targets are unaffected.

data PackageTargetProblem #

Constructors

PackageNameUnknown PackageName UserTarget |
PackageNameAmbiguous PackageName [PackageName] UserTarget |

#### Instances

Instances details

Show PackageTargetProblem # |
Instance details Defined in Distribution.Client.Targets Methods showsPrec :: Int -> PackageTargetProblem -> ShowS # show :: PackageTargetProblem -> String # showList :: [PackageTargetProblem] -> ShowS #

reportPackageTargetProblems :: Verbosity -> [PackageTargetProblem] -> IO () #

Report problems to the user. That is, if there are any problems then raise an exception.

disambiguatePackageTargets :: Package pkg' => PackageIndex pkg' -> [PackageName] -> [PackageTarget pkg] -> ([PackageTargetProblem], [PackageSpecifier pkg]) #

Users are allowed to give package names case-insensitively, so we must disambiguate named package references.

disambiguatePackageName :: PackageNameEnv -> PackageName -> MaybeAmbiguous PackageName #

Given a package name and a list of matching names, figure out which one it might be referring to. If there is an exact case-sensitive match then that's ok (i.e. returned via `Unambiguous`). If it matches just one package case-insensitively or if it matches multiple packages case-insensitively, in that case the result is `Ambiguous`.

Note: Before cabal 2.2, when only a single package matched case-insensitively it would be considered `Unambiguous`.

# User constraints

data UserQualifier #

Version of `Qualifier` that a user may specify on the command line.

Constructors

UserQualToplevel | Top-level dependency.
UserQualSetup PackageName | Setup dependency.
UserQualExe PackageName PackageName | Executable dependency.

#### Instances

Instances details

Structured UserQualifier # |
Instance details Defined in Distribution.Client.Targets Methods structure :: Proxy UserQualifier -> Structure # structureHash' :: Tagged UserQualifier MD5
Binary UserQualifier # |
Instance details Defined in Distribution.Client.Targets Methods put :: UserQualifier -> Put # get :: Get UserQualifier # putList :: [UserQualifier] -> Put #
Generic UserQualifier # |

Instance details

Defined in Distribution.Client.Targets

Associated Types

type Rep UserQualifier |

Instance details

Defined in Distribution.Client.Targets

type Rep UserQualifier = D1 ('MetaData "UserQualifier" "Distribution.Client.Targets" "cabal-install-3.12.1.0-G554PkJj2SpDqyarXp9tbt" 'False) (C1 ('MetaCons "UserQualToplevel" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "UserQualSetup" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName)) :+: C1 ('MetaCons "UserQualExe" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName))))

Methods

from :: UserQualifier -> Rep UserQualifier x #

to :: Rep UserQualifier x -> UserQualifier #

Show UserQualifier # |
Instance details Defined in Distribution.Client.Targets Methods showsPrec :: Int -> UserQualifier -> ShowS # show :: UserQualifier -> String # showList :: [UserQualifier] -> ShowS #
Eq UserQualifier # |
Instance details Defined in Distribution.Client.Targets Methods (==) :: UserQualifier -> UserQualifier -> Bool # (/=) :: UserQualifier -> UserQualifier -> Bool #
type Rep UserQualifier # |

Instance details

Defined in Distribution.Client.Targets

type Rep UserQualifier = D1 ('MetaData "UserQualifier" "Distribution.Client.Targets" "cabal-install-3.12.1.0-G554PkJj2SpDqyarXp9tbt" 'False) (C1 ('MetaCons "UserQualToplevel" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "UserQualSetup" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName)) :+: C1 ('MetaCons "UserQualExe" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName))))

data UserConstraintScope #

Version of `ConstraintScope` that a user may specify on the command line.

Constructors

UserQualified UserQualifier PackageName | Scope that applies to the package when it has the specified qualifier.
UserAnySetupQualifier PackageName | Scope that applies to the package when it has a setup qualifier.
UserAnyQualifier PackageName | Scope that applies to the package when it has any qualifier.

#### Instances

Instances details

Structured UserConstraintScope # |
Instance details Defined in Distribution.Client.Targets Methods structure :: Proxy UserConstraintScope -> Structure # structureHash' :: Tagged UserConstraintScope MD5
Binary UserConstraintScope # |
Instance details Defined in Distribution.Client.Targets Methods put :: UserConstraintScope -> Put # get :: Get UserConstraintScope # putList :: [UserConstraintScope] -> Put #
Generic UserConstraintScope # |

Instance details

Defined in Distribution.Client.Targets

Associated Types

type Rep UserConstraintScope |

Instance details

Defined in Distribution.Client.Targets

type Rep UserConstraintScope = D1 ('MetaData "UserConstraintScope" "Distribution.Client.Targets" "cabal-install-3.12.1.0-G554PkJj2SpDqyarXp9tbt" 'False) (C1 ('MetaCons "UserQualified" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UserQualifier) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName)) :+: (C1 ('MetaCons "UserAnySetupQualifier" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName)) :+: C1 ('MetaCons "UserAnyQualifier" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName))))

Methods

from :: UserConstraintScope -> Rep UserConstraintScope x #

to :: Rep UserConstraintScope x -> UserConstraintScope #

Show UserConstraintScope # |
Instance details Defined in Distribution.Client.Targets Methods showsPrec :: Int -> UserConstraintScope -> ShowS # show :: UserConstraintScope -> String # showList :: [UserConstraintScope] -> ShowS #
Eq UserConstraintScope # |
Instance details Defined in Distribution.Client.Targets Methods (==) :: UserConstraintScope -> UserConstraintScope -> Bool # (/=) :: UserConstraintScope -> UserConstraintScope -> Bool #
type Rep UserConstraintScope # |

Instance details

Defined in Distribution.Client.Targets

type Rep UserConstraintScope = D1 ('MetaData "UserConstraintScope" "Distribution.Client.Targets" "cabal-install-3.12.1.0-G554PkJj2SpDqyarXp9tbt" 'False) (C1 ('MetaCons "UserQualified" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UserQualifier) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName)) :+: (C1 ('MetaCons "UserAnySetupQualifier" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName)) :+: C1 ('MetaCons "UserAnyQualifier" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName))))

data UserConstraint #

Version of `PackageConstraint` that the user can specify on the command line.

Constructors

UserConstraint UserConstraintScope PackageProperty |

#### Instances

Instances details

Parsec UserConstraint # |
Instance details Defined in Distribution.Client.Targets Methods parsec :: CabalParsing m => m UserConstraint #
Pretty UserConstraint # |
Instance details Defined in Distribution.Client.Targets Methods pretty :: UserConstraint -> Doc # prettyVersioned :: CabalSpecVersion -> UserConstraint -> Doc #
Structured UserConstraint # |
Instance details Defined in Distribution.Client.Targets Methods structure :: Proxy UserConstraint -> Structure # structureHash' :: Tagged UserConstraint MD5
Binary UserConstraint # |
Instance details Defined in Distribution.Client.Targets Methods put :: UserConstraint -> Put # get :: Get UserConstraint # putList :: [UserConstraint] -> Put #
Generic UserConstraint # |

Instance details

Defined in Distribution.Client.Targets

Associated Types

type Rep UserConstraint |

Instance details

Defined in Distribution.Client.Targets

type Rep UserConstraint = D1 ('MetaData "UserConstraint" "Distribution.Client.Targets" "cabal-install-3.12.1.0-G554PkJj2SpDqyarXp9tbt" 'False) (C1 ('MetaCons "UserConstraint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UserConstraintScope) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageProperty)))

Methods

from :: UserConstraint -> Rep UserConstraint x #

to :: Rep UserConstraint x -> UserConstraint #

Show UserConstraint # |
Instance details Defined in Distribution.Client.Targets Methods showsPrec :: Int -> UserConstraint -> ShowS # show :: UserConstraint -> String # showList :: [UserConstraint] -> ShowS #
Eq UserConstraint # |
Instance details Defined in Distribution.Client.Targets Methods (==) :: UserConstraint -> UserConstraint -> Bool # (/=) :: UserConstraint -> UserConstraint -> Bool #
type Rep UserConstraint # |

Instance details

Defined in Distribution.Client.Targets

type Rep UserConstraint = D1 ('MetaData "UserConstraint" "Distribution.Client.Targets" "cabal-install-3.12.1.0-G554PkJj2SpDqyarXp9tbt" 'False) (C1 ('MetaCons "UserConstraint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UserConstraintScope) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageProperty)))

userConstraintPackageName :: UserConstraint -> PackageName #

readUserConstraint :: String -> Either String UserConstraint #

userToPackageConstraint :: UserConstraint -> PackageConstraint #