dhall-1.42.2: A configuration language guaranteed to terminate

Safe Haskell | None
Language | Haskell2010

Dhall.Util

Description

Shared utility functions

Synopsis

- snip :: Text -> Text
- snipDoc :: Doc Ann -> Doc a
- insert :: Pretty a => a -> Doc Ann
- _ERROR :: IsString string => string
- _WARNING :: IsString string => string
- printWarning :: MonadIO m => String -> m ()
- data Censor
  - = NoCensor
  - | Censor
- data Input
  - = StandardInput
  - | InputFile FilePath
- data Transitivity
  - = NonTransitive
  - | Transitive
- data OutputMode
  - = Write
  - | Check
- data Output
  - = StandardOutput
  - | OutputFile FilePath
- getExpression :: Censor -> Input -> IO (Expr Src Import)
- getExpressionAndHeader :: Censor -> Input -> IO (Header, Expr Src Import)
- getExpressionAndHeaderFromStdinText :: Censor -> String -> Text -> IO (Header, Expr Src Import)
- newtype Header = Header Text
- newtype CheckFailed = CheckFailed {
  - input :: Input
  }
- data MultipleCheckFailed = MultipleCheckFailed {
  - command :: Text
  - modified :: Text
  - inputs :: NonEmpty Input
  }
- handleMultipleChecksFailed :: (Foldable t, Traversable t) => Text -> Text -> (a -> IO (Either CheckFailed ())) -> t a -> IO ()
- renderExpression :: Pretty a => CharacterSet -> Bool -> Maybe FilePath -> Expr Src a -> IO ()

# Documentation

snip :: Text -> Text #

Utility function to cut out the interior of a large text block

snipDoc :: Doc Ann -> Doc a #

Like `snip`, but for `Doc`s

Note that this has to be opinionated and render ANSI color codes, but that should be fine because we don't use this in a non-interactive context

insert :: Pretty a => a -> Doc Ann #

Function to insert an aligned pretty expression

_ERROR :: IsString string => string #

Prefix used for error messages

_WARNING :: IsString string => string #

Prefix used for error messages

printWarning :: MonadIO m => String -> m () #

Output a warning message on stderr.

data Censor #

Set to `Censor` if you want to censor error text that might include secrets

Constructors

NoCensor |
Censor |

data Input #

Path to input

Constructors

StandardInput |
InputFile FilePath |

#### Instances

Instances details

Eq Input # |
Instance details Defined in Dhall.Util Methods (==) :: Input -> Input -> Bool # (/=) :: Input -> Input -> Bool #

data Transitivity #

Specifies whether or not an input's transitive dependencies should also be processed. Transitive dependencies are restricted to relative file imports.

Constructors

NonTransitive | Do not process transitive dependencies
Transitive | Process transitive dependencies in the same way

data OutputMode #

Some command-line subcommands can either `Write` their input or `Check` that the input has already been modified. This type is shared between them to record that choice.

Constructors

Write |
Check |

data Output #

Path to output

Constructors

StandardOutput |
OutputFile FilePath |

getExpression :: Censor -> Input -> IO (Expr Src Import) #

Convenient utility for retrieving an expression

getExpressionAndHeader :: Censor -> Input -> IO (Header, Expr Src Import) #

Convenient utility for retrieving an expression along with its header

getExpressionAndHeaderFromStdinText :: Censor -> String -> Text -> IO (Header, Expr Src Import) #

Convenient utility for retrieving an expression along with its header from | text already read from STDIN (so it's not re-read)

newtype Header #

A header corresponds to the leading comment at the top of a Dhall file.

The header includes comment characters but is stripped of leading spaces and trailing newlines

Constructors

Header Text |

#### Instances

Instances details

Show Header # |
Instance details Defined in Dhall.Parser Methods showsPrec :: Int -> Header -> ShowS # show :: Header -> String # showList :: [Header] -> ShowS #

newtype CheckFailed #

A check failure corresponding to a single input. This type is intended to be used with `MultipleCheckFailed` for error reporting.

Constructors

CheckFailed |

Fields

- input :: Input

data MultipleCheckFailed #

Exception thrown when the `--check` flag to a command-line subcommand fails

Constructors

MultipleCheckFailed |

Fields

- command :: Text
- modified :: Text
- inputs :: NonEmpty Input

#### Instances

Instances details

Exception MultipleCheckFailed # |
Instance details Defined in Dhall.Util Methods toException :: MultipleCheckFailed -> SomeException # fromException :: SomeException -> Maybe MultipleCheckFailed # displayException :: MultipleCheckFailed -> String # backtraceDesired :: MultipleCheckFailed -> Bool #
Show MultipleCheckFailed # |
Instance details Defined in Dhall.Util Methods showsPrec :: Int -> MultipleCheckFailed -> ShowS # show :: MultipleCheckFailed -> String # showList :: [MultipleCheckFailed] -> ShowS #

handleMultipleChecksFailed :: (Foldable t, Traversable t) => Text -> Text -> (a -> IO (Either CheckFailed ())) -> t a -> IO () #

Run IO for multiple inputs, then collate all the check failures before throwing if there was any failure

renderExpression :: Pretty a => CharacterSet -> Bool -> Maybe FilePath -> Expr Src a -> IO () #

Convenient utility to output an expression either to a file or to stdout.