tomland-1.0.0: Bidirectional TOML serialization

Safe HaskellNone
LanguageHaskell2010

Toml.Edsl

Description

This module introduces EDSL for manually specifying TOML data types.

Consider the following raw TOML:

key1 = 1
key2 = true

[meme-quotes]
  quote1 = [ "Oh", "Hi", "Mark" ]

[[arrayName]]
  elem1 = "yes"

[[arrayName]]
  [arrayName.elem2]
    deep = 7

[[arrayName]]

using functions from this module you can specify the above TOML in safer way:

exampleToml :: TOML
exampleToml = mkToml $ do
    "key1" =: 1
    "key2" =: Bool True
    table "meme-quotes" $
        "quote1" =: Array ["Oh", "Hi", "Mark"]
    tableArray "arrayName" $
        "elem1" =: "yes" :|
        [ table "elem2" $ "deep" =: Integer 7
        , empty
        ]
Synopsis

Documentation

type TDSL = State TOML () Source #

Monad for creating TOML.

mkToml :: TDSL -> TOML Source #

Creates TOML from the TDSL.

empty :: TDSL Source #

Creates an empty TDSL.

(=:) :: Key -> Value a -> TDSL Source #

Adds key-value pair to the TDSL.

table :: Key -> TDSL -> TDSL Source #

Adds table to the TDSL.

tableArray :: Key -> NonEmpty TDSL -> TDSL Source #

Adds array of tables to the TDSL.