dhall-1.32.0: 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
- data Censor
  - = NoCensor
  - | Censor
- data Input
  - = StandardInput
  - | InputFile FilePath
- 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 -> Text -> IO (Header, Expr Src Import)
- newtype Header = Header Text
- data CheckFailed = CheckFailed {
  - command :: Text
  - modified :: Text
  }

# Documentation

snip :: Text -> Text Source #

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

snipDoc :: Doc Ann -> Doc a Source #

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 Source #

Function to insert an aligned pretty expression

_ERROR :: IsString string => string Source #

Prefix used for error messages

data Censor Source #

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

Constructors

NoCensor |
Censor |

data Input Source #

Path to input

Constructors

StandardInput |
InputFile FilePath |

data OutputMode Source #

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 Source #

Path to output

Constructors

StandardOutput |
OutputFile FilePath |

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

Convenient utility for retrieving an expression

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

Convenient utility for retrieving an expression along with its header

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

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

newtype Header Source #

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 Source # |
Instance details Defined in Dhall.Parser Methods showsPrec :: Int -> Header -> ShowS Source # show :: Header -> String Source # showList :: [Header] -> ShowS Source #

data CheckFailed Source #

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

Constructors

CheckFailed |

Fields

- command :: Text
- modified :: Text

#### Instances

Instances details

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