Toml.Parser.Item

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.Parser.Item

Description

This module contains the definition of the `TomlItem` data type which represents either key-value pair or table name. This data type serves the purpose to be the intermediate representation of parsing a TOML file which will be assembled to TOML AST later.

Since: 1.2.0.0

Synopsis

- data TomlItem
  - = TableName !Key
  - | TableArrayName !Key
  - | KeyVal !Key !AnyValue
  - | InlineTable !Key !Table
  - | InlineTableArray !Key !(NonEmpty Table)
- newtype Table = Table {
  - unTable :: [(Key, AnyValue)]
  }
- setTableName :: Key -> TomlItem -> TomlItem
- tomlP :: Parser [TomlItem]
- keyValP :: Parser TomlItem

# Documentation

data TomlItem #

One item of a TOML file. It could be either:

- A name of a table
- A name of a table array
- Key-value pair
- Inline table
- Inline array of tables

Knowing a list of `TomlItem`s, it's possible to construct `TOML` from this information.

Constructors

TableName !Key |
TableArrayName !Key |
KeyVal !Key !AnyValue |
InlineTable !Key !Table |
InlineTableArray !Key !(NonEmpty Table) |

#### Instances

Instances details

Show TomlItem # |
Instance details Defined in Toml.Parser.Item Methods showsPrec :: Int -> TomlItem -> ShowS # show :: TomlItem -> String # showList :: [TomlItem] -> ShowS #
Eq TomlItem # |
Instance details Defined in Toml.Parser.Item Methods (==) :: TomlItem -> TomlItem -> Bool # (/=) :: TomlItem -> TomlItem -> Bool #

newtype Table #

Table that contains only `key = val` pairs.

Constructors

Table |
Fields unTable :: [(Key, AnyValue)]

#### Instances

Instances details

Show Table # |
Instance details Defined in Toml.Parser.Item Methods showsPrec :: Int -> Table -> ShowS # show :: Table -> String # showList :: [Table] -> ShowS #
Eq Table # |
Instance details Defined in Toml.Parser.Item Methods (==) :: Table -> Table -> Bool # (/=) :: Table -> Table -> Bool #

setTableName :: Key -> TomlItem -> TomlItem #

Changes name of table to a new one. Works only for `TableName` and `TableArrayName` constructors.

tomlP :: Parser [TomlItem] #

Parser for the full content of the .toml file.

keyValP :: Parser TomlItem #

parser for `"key = val"` pairs; can be one of three forms:

1. key = { ... }
2. key = [ {...}, {...}, ... ]
3. key = ...