tomland-1.3.0.0: Bidirectional TOML serialization
Copyright(c) 2018-2020 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Toml.Type.Printer

Description

Contains functions for pretty printing toml types.

Since: 0.0.0

Synopsis

Documentation

data PrintOptions Source #

Configures the pretty printer.

Since: 0.5.0

Constructors

PrintOptions 

Fields

defaultOptions :: PrintOptions Source #

Default printing options.

  1. Sorts all keys and tables by name.
  2. 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

prettyKey :: Key -> Text Source #

Converts a key to text

Since: 0.0.0