toml-parser-2.0.2.0: TOML 1.1.0 parser

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

Toml.Syntax.Parser

Contents

- Types
- Parser

Description

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

Synopsis

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

# Types

data Expr a Source #

Headers and assignments corresponding to lines of a TOML file

Constructors

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

#### Instances

Instances details

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

data SectionKind Source #

Kinds of table headers

Constructors

TableKind

table

ArrayTableKind

[array of tables
  ]

#### Instances

Instances details

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

data Val a Source #

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

Constructors

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

#### Instances

Instances details

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

type Key a = NonEmpty (a, Text) Source #

Non-empty sequence of dotted simple keys

# Parser

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

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.