Toml.Type.Edsl

tomland-1.3.3.3: Bidirectional TOML serialization

Copyright | (c) 2018-2022 Kowainik
License | MPL-2.0
Maintainer | Kowainik <xrom.xkov@gmail.com>
Stability | Stable
Portability | Portable
Safe Haskell | None
Language | Haskell2010

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

- type TDSL = State TOML ()
- mkToml :: TDSL -> TOML
- empty :: TDSL
- (=:) :: forall (a :: TValue). Key -> Value a -> TDSL
- table :: Key -> TDSL -> TDSL
- tableArray :: Key -> NonEmpty TDSL -> TDSL

# Documentation

type TDSL = State TOML () #

Monad for creating TOML.

Since: 0.3

mkToml :: TDSL -> TOML #

Creates `TOML` from the `TDSL`.

Since: 0.3

empty :: TDSL #

Creates an empty `TDSL`.

Since: 0.3

(=:) :: forall (a :: TValue). Key -> Value a -> TDSL #

Adds key-value pair to the `TDSL`.

Since: 0.3

table :: Key -> TDSL -> TDSL #

Adds table to the `TDSL`.

Since: 0.3

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

Adds array of tables to the `TDSL`.

Since: 1.0.0