tomland-1.1.0.0: Bidirectional TOML serialization

Safe HaskellNone
LanguageHaskell2010

Toml.Printer

Description

Contains functions for pretty printing toml types.

Synopsis

Documentation

data PrintOptions Source #

Configures the pretty printer.

Constructors

PrintOptions 

Fields

defaultOptions :: PrintOptions Source #

Default printing options.

  1. Sorts all keys and tables by name.
  2. Indents with 2 spaces.

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"

prettyOptions :: PrintOptions -> TOML -> Text Source #

Converts TOML type into Text using provided PrintOptions

prettyKey :: Key -> Text Source #

Converts a key to text