tomland-1.3.3.3: Bidirectional TOML serialization
Copyright(c) 2018-2022 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
StabilityStable
PortabilityPortable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Toml.Type.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
        ]

Since: 0.3

Synopsis

Documentation

type TDSL = State TOML () Source #

Monad for creating TOML.

Since: 0.3

mkToml :: TDSL -> TOML Source #

Creates TOML from the TDSL.

Since: 0.3

empty :: TDSL Source #

Creates an empty TDSL.

Since: 0.3

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

Adds key-value pair to the TDSL.

Since: 0.3

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

Adds table to the TDSL.

Since: 0.3

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

Adds array of tables to the TDSL.

Since: 1.0.0