| Copyright | (c) 2018-2021 Kowainik |
|---|---|
| License | MPL-2.0 |
| Maintainer | Kowainik <xrom.xkov@gmail.com> |
| Stability | Stable |
| Portability | Portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Toml.Type.Printer
Description
Contains functions for pretty printing toml types.
Since: 0.0.0
Synopsis
- data PrintOptions = PrintOptions {
- printOptionsSorting :: !(Maybe (Key -> Key -> Ordering))
- printOptionsIndent :: !Int
- printOptionsLines :: !Lines
- data Lines
- defaultOptions :: PrintOptions
- pretty :: TOML -> Text
- prettyOptions :: PrintOptions -> TOML -> Text
- prettyKey :: Key -> Text
Documentation
data PrintOptions Source #
Configures the pretty printer.
Since: 0.5.0
Constructors
| PrintOptions | |
Fields
| |
defaultOptions :: PrintOptions Source #
Default printing options.
- Sorts all keys and tables by name.
- Indents with 2 spaces.
Since: 0.5.0
pretty :: TOML -> Text Source #
Converts TOML type into Text (using defaultOptions).
For example, this
TOML
{ tomlPairs = HashMap.fromList
[("title", AnyValue $ Text "TOML example")]
, tomlTables = PrefixTree.fromList
[( "example" <| "owner"
, mempty
{ tomlPairs = HashMap.fromList
[("name", AnyValue $ Text Kowainik)]
}
)]
, tomlTableArrays = mempty
}
will be translated to this
title = "TOML Example" [example.owner] name = "Kowainik"
Since: 0.0.0
prettyOptions :: PrintOptions -> TOML -> Text Source #
Converts TOML type into Text using provided PrintOptions
Since: 0.5.0