Copyright | (c) Duncan Coutts 2011 |
---|---|
License | BSD-like |
Maintainer | duncan@community.haskell.org |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Handling for user-specified targets
Synopsis
- data UserTarget
- readUserTargets :: Verbosity -> [String] -> IO [UserTarget]
- resolveUserTargets :: Package pkg => Verbosity -> RepoContext -> PackageIndex pkg -> [UserTarget] -> IO [PackageSpecifier UnresolvedSourcePackage]
- data UserTargetProblem
- readUserTarget :: String -> IO (Either UserTargetProblem UserTarget)
- reportUserTargetProblems :: Verbosity -> [UserTargetProblem] -> IO ()
- expandUserTarget :: Verbosity -> UserTarget -> IO [PackageTarget (PackageLocation ())]
- data PackageTarget pkg
- fetchPackageTarget :: Verbosity -> RepoContext -> PackageTarget (PackageLocation ()) -> IO (PackageTarget ResolvedPkgLoc)
- readPackageTarget :: Verbosity -> PackageTarget ResolvedPkgLoc -> IO (PackageTarget UnresolvedSourcePackage)
- data PackageTargetProblem
- reportPackageTargetProblems :: Verbosity -> [PackageTargetProblem] -> IO ()
- disambiguatePackageTargets :: Package pkg' => PackageIndex pkg' -> [PackageName] -> [PackageTarget pkg] -> ([PackageTargetProblem], [PackageSpecifier pkg])
- disambiguatePackageName :: PackageNameEnv -> PackageName -> MaybeAmbiguous PackageName
- data UserQualifier
- data UserConstraintScope
- data UserConstraint = UserConstraint UserConstraintScope PackageProperty
- userConstraintPackageName :: UserConstraint -> PackageName
- readUserConstraint :: String -> Either String UserConstraint
- userToPackageConstraint :: UserConstraint -> PackageConstraint
User targets
data UserTarget Source #
Various ways that a user may specify a package or package collection.
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
|
UserTargetLocalCabalFile FilePath | A specific local unpacked package, identified by its 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
Show UserTarget Source # | |
Defined in Distribution.Client.Targets showsPrec :: Int -> UserTarget -> ShowS # show :: UserTarget -> String # showList :: [UserTarget] -> ShowS # | |
Eq UserTarget Source # | |
Defined in Distribution.Client.Targets (==) :: UserTarget -> UserTarget -> Bool # (/=) :: UserTarget -> UserTarget -> Bool # |
readUserTargets :: Verbosity -> [String] -> IO [UserTarget] Source #
Resolving user targets to package specifiers
resolveUserTargets :: Package pkg => Verbosity -> RepoContext -> PackageIndex pkg -> [UserTarget] -> IO [PackageSpecifier UnresolvedSourcePackage] Source #
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 Source #
UserTargetUnexpectedFile String | |
UserTargetNonexistantFile String | |
UserTargetUnexpectedUriScheme String | |
UserTargetUnrecognisedUri String | |
UserTargetUnrecognised String |
Instances
Show UserTargetProblem Source # | |
Defined in Distribution.Client.Targets showsPrec :: Int -> UserTargetProblem -> ShowS # show :: UserTargetProblem -> String # showList :: [UserTargetProblem] -> ShowS # |
reportUserTargetProblems :: Verbosity -> [UserTargetProblem] -> IO () Source #
expandUserTarget :: Verbosity -> UserTarget -> IO [PackageTarget (PackageLocation ())] Source #
Given a user-specified target, expand it to a bunch of package targets (each of which refers to only one package).
data PackageTarget pkg Source #
An intermediate between a UserTarget
and a resolved PackageSpecifier
.
Unlike a UserTarget
, a PackageTarget
refers only to a single package.
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
fetchPackageTarget :: Verbosity -> RepoContext -> PackageTarget (PackageLocation ()) -> IO (PackageTarget ResolvedPkgLoc) Source #
Fetch any remote targets so that they can be read.
readPackageTarget :: Verbosity -> PackageTarget ResolvedPkgLoc -> IO (PackageTarget UnresolvedSourcePackage) Source #
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 Source #
Instances
Show PackageTargetProblem Source # | |
Defined in Distribution.Client.Targets showsPrec :: Int -> PackageTargetProblem -> ShowS # show :: PackageTargetProblem -> String # showList :: [PackageTargetProblem] -> ShowS # |
reportPackageTargetProblems :: Verbosity -> [PackageTargetProblem] -> IO () Source #
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]) Source #
Users are allowed to give package names case-insensitively, so we must disambiguate named package references.
disambiguatePackageName :: PackageNameEnv -> PackageName -> MaybeAmbiguous PackageName Source #
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 Source #
Version of Qualifier
that a user may specify on the
command line.
UserQualToplevel | Top-level dependency. |
UserQualSetup PackageName | Setup dependency. |
UserQualExe PackageName PackageName | Executable dependency. |
Instances
data UserConstraintScope Source #
Version of ConstraintScope
that a user may specify on the
command line.
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
data UserConstraint Source #
Version of PackageConstraint
that the user can specify on
the command line.