Safe Haskell | None |
---|---|
Language | Haskell2010 |
Contains functions for pretty printing toml
types.
Synopsis
- data PrintOptions = PrintOptions {
- shouldSort :: Bool
- indent :: Int
- defaultOptions :: PrintOptions
- pretty :: TOML -> Text
- prettyOptions :: PrintOptions -> TOML -> Text
- prettyKey :: Key -> Text
Documentation
data PrintOptions Source #
Configures the pretty printer.
PrintOptions | |
|
Instances
Show PrintOptions Source # | |
Defined in Toml.Printer showsPrec :: Int -> PrintOptions -> ShowS # show :: PrintOptions -> String # showList :: [PrintOptions] -> ShowS # |
defaultOptions :: PrintOptions Source #
Default printing options.
- Sorts all keys and tables by name.
- 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