Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Utilities to help format error messages for the various CLI commands.
Synopsis
- data Plural
- plural :: Plural -> a -> a -> a
- listPlural :: [a] -> Plural
- renderListCommaAnd :: [String] -> String
- renderListTabular :: [String] -> String
- renderListPretty :: [String] -> String
- renderListSemiAnd :: [String] -> String
- sortGroupOn :: Ord b => (a -> b) -> [a] -> [(b, [a])]
- renderTargetSelector :: TargetSelector -> String
- renderSubComponentTarget :: SubComponentTarget -> String
- renderOptionalStanza :: Plural -> OptionalStanza -> String
- optionalStanza :: ComponentName -> Maybe OptionalStanza
- targetSelectorPluralPkgs :: TargetSelector -> Plural
- targetSelectorRefersToPkgs :: TargetSelector -> Bool
- targetSelectorFilter :: TargetSelector -> Maybe ComponentKindFilter
- renderComponentName :: PackageName -> ComponentName -> String
- renderComponentKind :: Plural -> ComponentKind -> String
- reportTargetProblems :: Verbosity -> String -> [TargetProblem'] -> IO a
- renderTargetProblem :: String -> (a -> String) -> TargetProblem a -> String
- renderTargetProblemNoneEnabled :: String -> TargetSelector -> [AvailableTarget ()] -> String
- renderTargetProblemNoTargets :: String -> TargetSelector -> String
- renderCannotPruneDependencies :: CannotPruneDependencies -> String
- data SubComponentTarget
- type ComponentKindFilter = ComponentKind
- data ComponentKind
- data TargetSelector
- = TargetPackage TargetImplicitCwd [PackageId] (Maybe ComponentKindFilter)
- | TargetPackageNamed PackageName (Maybe ComponentKindFilter)
- | TargetAllPackages (Maybe ComponentKindFilter)
- | TargetComponent PackageId ComponentName SubComponentTarget
- | TargetComponentUnknown PackageName (Either UnqualComponentName ComponentName) SubComponentTarget
- showTargetSelector :: TargetSelector -> String
- componentKind :: ComponentName -> ComponentKind
Documentation
A tag used in rendering messages to distinguish singular or plural.
plural :: Plural -> a -> a -> a Source #
Used to render a singular or plural version of something
plural (listPlural theThings) "it is" "they are"
listPlural :: [a] -> Plural Source #
Singular for singleton lists and plural otherwise.
renderListCommaAnd :: [String] -> String Source #
Render a list of things in the style foo, bar and baz
renderListTabular :: [String] -> String Source #
renderListPretty :: [String] -> String Source #
renderListSemiAnd :: [String] -> String Source #
Render a list of things in the style blah blah; this that; and the other
sortGroupOn :: Ord b => (a -> b) -> [a] -> [(b, [a])] Source #
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 ]
renderOptionalStanza :: Plural -> OptionalStanza -> String Source #
optionalStanza :: ComponentName -> Maybe OptionalStanza Source #
The optional stanza type (test suite or benchmark), if it is one.
targetSelectorPluralPkgs :: TargetSelector -> Plural Source #
Does the TargetSelector
potentially refer to one package or many?
targetSelectorRefersToPkgs :: TargetSelector -> Bool Source #
Does the TargetSelector
refer to packages or to components?
renderComponentName :: PackageName -> ComponentName -> String Source #
renderComponentKind :: Plural -> ComponentKind -> String Source #
reportTargetProblems :: Verbosity -> String -> [TargetProblem'] -> IO a Source #
Default implementation of reportTargetProblems
simply renders one problem per line.
:: String | verb |
-> (a -> String) | how to render custom problems |
-> TargetProblem a | |
-> String |
Default implementation of renderTargetProblem
.
renderTargetProblemNoneEnabled :: String -> TargetSelector -> [AvailableTarget ()] -> String Source #
Several commands have a TargetProblemNoneEnabled
problem constructor.
This renders an error message for those cases.
renderTargetProblemNoTargets :: String -> TargetSelector -> String Source #
Several commands have a TargetProblemNoTargets
problem constructor.
This renders an error message for those cases.
data SubComponentTarget Source #
Either the component as a whole or detail about a file or module target within a component.
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
type ComponentKindFilter = ComponentKind Source #
data ComponentKind Source #
Instances
data TargetSelector Source #
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 ]
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 |
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. |