toml-parser-1.3.0.0: TOML 1.0.0 parser

Copyright | (c) Eric Mertens 2023
License | ISC
Maintainer | emertens@gmail.com
Safe Haskell | Safe-Inferred
Language | Haskell2010

Toml.Parser

Contents

- Types
- Parser

Description

This module parses TOML tokens into a list of raw, uninterpreted sections and assignments.

Synopsis

- data Expr
  - = KeyValExpr Key Val
  - | TableExpr Key
  - | ArrayTableExpr Key
- data SectionKind
  - = TableKind
  - | ArrayTableKind
- data Val
  - = ValInteger Integer
  - | ValFloat Double
  - | ValArray [Val]
  - | ValTable [(Key, Val)]
  - | ValBool Bool
  - | ValString String
  - | ValTimeOfDay TimeOfDay
  - | ValZonedTime ZonedTime
  - | ValLocalTime LocalTime
  - | ValDay Day
- type Key = NonEmpty (Located String)
- parseRawToml :: String -> Either (Located String) [Expr]

# Types

data Expr #

Headers and assignments corresponding to lines of a TOML file

Constructors

KeyValExpr Key Val | key value assignment: `key = value`
TableExpr Key | table: `[key]`
ArrayTableExpr Key | array of tables: `[[key]]`

#### Instances

Instances details

Read Expr # |
Instance details Defined in Toml.Parser.Types Methods readsPrec :: Int -> ReadS Expr readList :: ReadS [Expr] readPrec :: ReadPrec Expr readListPrec :: ReadPrec [Expr]
Show Expr # |
Instance details Defined in Toml.Parser.Types Methods showsPrec :: Int -> Expr -> ShowS show :: Expr -> String showList :: [Expr] -> ShowS

data SectionKind #

Kinds of table headers.

Constructors

TableKind

table

ArrayTableKind

[array of tables
  ]

#### Instances

Instances details

Read SectionKind # |
Instance details Defined in Toml.Parser.Types Methods readsPrec :: Int -> ReadS SectionKind readList :: ReadS [SectionKind] readPrec :: ReadPrec SectionKind readListPrec :: ReadPrec [SectionKind]
Show SectionKind # |
Instance details Defined in Toml.Parser.Types Methods showsPrec :: Int -> SectionKind -> ShowS show :: SectionKind -> String showList :: [SectionKind] -> ShowS
Eq SectionKind # |
Instance details Defined in Toml.Parser.Types Methods (==) :: SectionKind -> SectionKind -> Bool (/=) :: SectionKind -> SectionKind -> Bool

data Val #

Unvalidated TOML values. Table are represented as a list of assignments rather than as resolved maps.

Constructors

ValInteger Integer |
ValFloat Double |
ValArray [Val] |
ValTable [(Key, Val)] |
ValBool Bool |
ValString String |
ValTimeOfDay TimeOfDay |
ValZonedTime ZonedTime |
ValLocalTime LocalTime |
ValDay Day |

#### Instances

Instances details

Read Val # |
Instance details Defined in Toml.Parser.Types Methods readsPrec :: Int -> ReadS Val readList :: ReadS [Val] readPrec :: ReadPrec Val readListPrec :: ReadPrec [Val]
Show Val # |
Instance details Defined in Toml.Parser.Types Methods showsPrec :: Int -> Val -> ShowS show :: Val -> String showList :: [Val] -> ShowS

type Key = NonEmpty (Located String) #

Non-empty sequence of dotted simple keys

# Parser

parseRawToml :: String -> Either (Located String) [Expr] #

Parse a list of tokens either returning the first unexpected token or a list of the TOML statements in the file to be processed by Toml.Semantics.