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

Safe Haskell | None
Language | Haskell2010

Distribution.Client.CmdErrorMessages

Description

Utilities to help format error messages for the various CLI commands.

Synopsis

- renderTargetSelector :: TargetSelector -> String
- renderTargetProblem :: String -> (a -> String) -> TargetProblem a -> String
- renderTargetProblemNoTargets :: String -> TargetSelector -> String
- plural :: Plural -> a -> a -> a
- targetSelectorPluralPkgs :: TargetSelector -> Plural
- targetSelectorFilter :: TargetSelector -> Maybe ComponentKindFilter
- renderListCommaAnd :: [String] -> String
- targetSelectorRefersToPkgs :: TargetSelector -> Bool
- renderComponentKind :: Plural -> ComponentKind -> String
- renderListSemiAnd :: [String] -> String
- sortGroupOn :: Ord b => (a -> b) -> [a] -> [(b, [a])]
- data Plural
  - = Singular
  - | Plural
- renderListPretty :: [String] -> String
- listPlural :: [a] -> Plural
- renderListTabular :: [String] -> String
- renderSubComponentTarget :: SubComponentTarget -> String
- renderComponentName :: PackageName -> ComponentName -> String
- renderOptionalStanza :: Plural -> OptionalStanza -> String
- optionalStanza :: ComponentName -> Maybe OptionalStanza
- reportTargetProblems :: Verbosity -> String -> [TargetProblem'] -> IO a
- renderTargetProblemNoneEnabled :: String -> TargetSelector -> [AvailableTarget ()] -> String
- renderCannotPruneDependencies :: CannotPruneDependencies -> String
- showTargetSelector :: TargetSelector -> String
- data TargetSelector
  - = TargetPackage TargetImplicitCwd [PackageId] (Maybe ComponentKindFilter)
  - | TargetPackageNamed PackageName (Maybe ComponentKindFilter)
  - | TargetAllPackages (Maybe ComponentKindFilter)
  - | TargetComponent PackageId ComponentName SubComponentTarget
  - | TargetComponentUnknown PackageName (Either UnqualComponentName ComponentName) SubComponentTarget
- data SubComponentTarget
  - = WholeComponent
  - | ModuleTarget ModuleName
  - | FileTarget FilePath
- data ComponentKind
  - = LibKind
  - | FLibKind
  - | ExeKind
  - | TestKind
  - | BenchKind
- type ComponentKindFilter = ComponentKind
- componentKind :: ComponentName -> ComponentKind

# Documentation

renderTargetSelector :: TargetSelector -> String #

renderTargetProblem #

Arguments

:: String | verb
-> (a -> String) | how to render custom problems
-> TargetProblem a |
-> String |

Default implementation of `renderTargetProblem`.

renderTargetProblemNoTargets :: String -> TargetSelector -> String #

Several commands have a `TargetProblemNoTargets` problem constructor. This renders an error message for those cases.

plural :: Plural -> a -> a -> a #

Used to render a singular or plural version of something

    plural (listPlural theThings) "it is" "they are"

targetSelectorPluralPkgs :: TargetSelector -> Plural #

Does the `TargetSelector` potentially refer to one package or many?

targetSelectorFilter :: TargetSelector -> Maybe ComponentKindFilter #

renderListCommaAnd :: [String] -> String #

Render a list of things in the style `foo, bar and baz`

targetSelectorRefersToPkgs :: TargetSelector -> Bool #

Does the `TargetSelector` refer to packages or to components?

renderComponentKind :: Plural -> ComponentKind -> String #

renderListSemiAnd :: [String] -> String #

Render a list of things in the style `blah blah; this that; and the other`

sortGroupOn :: Ord b => (a -> b) -> [a] -> [(b, [a])] #

When rendering lists of things it often reads better to group related things, e.g. grouping components by package name

    renderListSemiAnd
      [     "the package " ++ prettyShow pkgname ++ " components "
         ++ renderListCommaAnd showComponentName components
      | (pkgname, components) <- sortGroupOn packageName allcomponents ]

data Plural #

A tag used in rendering messages to distinguish singular or plural.

Constructors

Singular |
Plural |

renderListPretty :: [String] -> String #

listPlural :: [a] -> Plural #

Singular for singleton lists and plural otherwise.

renderListTabular :: [String] -> String #

renderSubComponentTarget :: SubComponentTarget -> String #

renderComponentName :: PackageName -> ComponentName -> String #

renderOptionalStanza :: Plural -> OptionalStanza -> String #

optionalStanza :: ComponentName -> Maybe OptionalStanza #

The optional stanza type (test suite or benchmark), if it is one.

reportTargetProblems :: Verbosity -> String -> [TargetProblem'] -> IO a #

Default implementation of `reportTargetProblems` simply renders one problem per line.

renderTargetProblemNoneEnabled :: String -> TargetSelector -> [AvailableTarget ()] -> String #

Several commands have a `TargetProblemNoneEnabled` problem constructor. This renders an error message for those cases.

renderCannotPruneDependencies :: CannotPruneDependencies -> String #

showTargetSelector :: TargetSelector -> String #

data TargetSelector #

A target selector is expression selecting a set of components (as targets for a actions like `build`, `run`, `test` etc). A target selector corresponds to the user syntax for referring to targets on the command line.

From the users point of view a target can be many things: packages, dirs, component names, files etc. Internally we consider a target to be a specific component (or module/file within a component), and all the users' notions of targets are just different ways of referring to these component targets.

So target selectors are expressions in the sense that they are interpreted to refer to one or more components. For example a `TargetPackage` gets interpreted differently by different commands to refer to all or a subset of components within the package.

The syntax has lots of optional parts:

    [ package name | package dir | package .cabal file ]
    [ [lib:|exe:] component name ]
    [ module name | source file ]

Constructors

TargetPackage TargetImplicitCwd [PackageId] (Maybe ComponentKindFilter) | One (or more) packages as a whole, or all the components of a particular kind within the package(s). These are always packages that are local to the project. In the case that there is more than one, they all share the same directory location.
TargetPackageNamed PackageName (Maybe ComponentKindFilter) | A package specified by name. This may refer to `extra-packages` from the `cabal.project` file, or a dependency of a known project package or could refer to a package from a hackage archive. It needs further context to resolve to a specific package.
TargetAllPackages (Maybe ComponentKindFilter) | All packages, or all components of a particular kind in all packages.
TargetComponent PackageId ComponentName SubComponentTarget | A specific component in a package within the project.
TargetComponentUnknown PackageName (Either UnqualComponentName ComponentName) SubComponentTarget | A component in a package, but where it cannot be verified that the package has such a component, or because the package is itself not known.

#### Instances

Instances details

Generic TargetSelector # |
Instance details Defined in Distribution.Client.TargetSelector Associated Types
type Rep TargetSelector |
Instance details Defined in Distribution.Client.TargetSelector type Rep TargetSelector = D1 ('MetaData "TargetSelector" "Distribution.Client.TargetSelector" "cabal-install-3.10.2.1-EH6AEtqwlbKE3rh89dIk81" 'False) ((C1 ('MetaCons "TargetPackage" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TargetImplicitCwd) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [PackageId]) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ComponentKindFilter)))) :+: C1 ('MetaCons "TargetPackageNamed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ComponentKindFilter)))) :+: (C1 ('MetaCons "TargetAllPackages" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ComponentKindFilter))) :+: (C1 ('MetaCons "TargetComponent" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageId) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ComponentName) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SubComponentTarget))) :+: C1 ('MetaCons "TargetComponentUnknown" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Either UnqualComponentName ComponentName)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SubComponentTarget))))))
Methods from :: TargetSelector -> Rep TargetSelector x # to :: Rep TargetSelector x -> TargetSelector #
Show TargetSelector # |
Instance details Defined in Distribution.Client.TargetSelector Methods showsPrec :: Int -> TargetSelector -> ShowS # show :: TargetSelector -> String # showList :: [TargetSelector] -> ShowS #
Eq TargetSelector # |
Instance details Defined in Distribution.Client.TargetSelector Methods (==) :: TargetSelector -> TargetSelector -> Bool # (/=) :: TargetSelector -> TargetSelector -> Bool #
Ord TargetSelector # |
Instance details Defined in Distribution.Client.TargetSelector Methods compare :: TargetSelector -> TargetSelector -> Ordering # (<) :: TargetSelector -> TargetSelector -> Bool # (<=) :: TargetSelector -> TargetSelector -> Bool # (>) :: TargetSelector -> TargetSelector -> Bool # (>=) :: TargetSelector -> TargetSelector -> Bool # max :: TargetSelector -> TargetSelector -> TargetSelector # min :: TargetSelector -> TargetSelector -> TargetSelector #
type Rep TargetSelector # |
Instance details Defined in Distribution.Client.TargetSelector type Rep TargetSelector = D1 ('MetaData "TargetSelector" "Distribution.Client.TargetSelector" "cabal-install-3.10.2.1-EH6AEtqwlbKE3rh89dIk81" 'False) ((C1 ('MetaCons "TargetPackage" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TargetImplicitCwd) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [PackageId]) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ComponentKindFilter)))) :+: C1 ('MetaCons "TargetPackageNamed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ComponentKindFilter)))) :+: (C1 ('MetaCons "TargetAllPackages" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ComponentKindFilter))) :+: (C1 ('MetaCons "TargetComponent" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageId) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ComponentName) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SubComponentTarget))) :+: C1 ('MetaCons "TargetComponentUnknown" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Either UnqualComponentName ComponentName)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SubComponentTarget))))))

data SubComponentTarget #

Either the component as a whole or detail about a file or module target within a component.

Constructors

WholeComponent | The component as a whole
ModuleTarget ModuleName | A specific module within a component.
FileTarget FilePath | A specific file within a component. Note that this does not carry the file extension.

#### Instances

Instances details

Structured SubComponentTarget # |
Instance details Defined in Distribution.Client.TargetSelector Methods structure :: Proxy SubComponentTarget -> Structure # structureHash' :: Tagged SubComponentTarget MD5
Generic SubComponentTarget # |
Instance details Defined in Distribution.Client.TargetSelector Associated Types
type Rep SubComponentTarget |
Instance details Defined in Distribution.Client.TargetSelector type Rep SubComponentTarget = D1 ('MetaData "SubComponentTarget" "Distribution.Client.TargetSelector" "cabal-install-3.10.2.1-EH6AEtqwlbKE3rh89dIk81" 'False) (C1 ('MetaCons "WholeComponent" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ModuleTarget" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModuleName)) :+: C1 ('MetaCons "FileTarget" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath))))
Methods from :: SubComponentTarget -> Rep SubComponentTarget x # to :: Rep SubComponentTarget x -> SubComponentTarget #
Show SubComponentTarget # |
Instance details Defined in Distribution.Client.TargetSelector Methods showsPrec :: Int -> SubComponentTarget -> ShowS # show :: SubComponentTarget -> String # showList :: [SubComponentTarget] -> ShowS #
Binary SubComponentTarget # |
Instance details Defined in Distribution.Client.TargetSelector Methods put :: SubComponentTarget -> Put # get :: Get SubComponentTarget # putList :: [SubComponentTarget] -> Put #
Eq SubComponentTarget # |
Instance details Defined in Distribution.Client.TargetSelector Methods (==) :: SubComponentTarget -> SubComponentTarget -> Bool # (/=) :: SubComponentTarget -> SubComponentTarget -> Bool #
Ord SubComponentTarget # |
Instance details Defined in Distribution.Client.TargetSelector Methods compare :: SubComponentTarget -> SubComponentTarget -> Ordering # (<) :: SubComponentTarget -> SubComponentTarget -> Bool # (<=) :: SubComponentTarget -> SubComponentTarget -> Bool # (>) :: SubComponentTarget -> SubComponentTarget -> Bool # (>=) :: SubComponentTarget -> SubComponentTarget -> Bool # max :: SubComponentTarget -> SubComponentTarget -> SubComponentTarget # min :: SubComponentTarget -> SubComponentTarget -> SubComponentTarget #
type Rep SubComponentTarget # |
Instance details Defined in Distribution.Client.TargetSelector type Rep SubComponentTarget = D1 ('MetaData "SubComponentTarget" "Distribution.Client.TargetSelector" "cabal-install-3.10.2.1-EH6AEtqwlbKE3rh89dIk81" 'False) (C1 ('MetaCons "WholeComponent" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ModuleTarget" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModuleName)) :+: C1 ('MetaCons "FileTarget" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath))))

data ComponentKind #

Constructors

LibKind |
FLibKind |
ExeKind |
TestKind |
BenchKind |

#### Instances

Instances details

Enum ComponentKind # |
Instance details Defined in Distribution.Client.TargetSelector Methods succ :: ComponentKind -> ComponentKind # pred :: ComponentKind -> ComponentKind # toEnum :: Int -> ComponentKind # fromEnum :: ComponentKind -> Int # enumFrom :: ComponentKind -> [ComponentKind] # enumFromThen :: ComponentKind -> ComponentKind -> [ComponentKind] # enumFromTo :: ComponentKind -> ComponentKind -> [ComponentKind] # enumFromThenTo :: ComponentKind -> ComponentKind -> ComponentKind -> [ComponentKind] #
Show ComponentKind # |
Instance details Defined in Distribution.Client.TargetSelector Methods showsPrec :: Int -> ComponentKind -> ShowS # show :: ComponentKind -> String # showList :: [ComponentKind] -> ShowS #
Eq ComponentKind # |
Instance details Defined in Distribution.Client.TargetSelector Methods (==) :: ComponentKind -> ComponentKind -> Bool # (/=) :: ComponentKind -> ComponentKind -> Bool #
Ord ComponentKind # |
Instance details Defined in Distribution.Client.TargetSelector Methods compare :: ComponentKind -> ComponentKind -> Ordering # (<) :: ComponentKind -> ComponentKind -> Bool # (<=) :: ComponentKind -> ComponentKind -> Bool # (>) :: ComponentKind -> ComponentKind -> Bool # (>=) :: ComponentKind -> ComponentKind -> Bool # max :: ComponentKind -> ComponentKind -> ComponentKind # min :: ComponentKind -> ComponentKind -> ComponentKind #

type ComponentKindFilter = ComponentKind #

componentKind :: ComponentName -> ComponentKind #