htoml-0.1.0.1: A parser for TOML files.

Safe HaskellNone
LanguageHaskell2010

Text.Toml.Types

Contents

Synopsis

Documentation

type Table = HashMap Text Node Source

The Table is a mapping (HashMap) of Text keys to Node values.

data Node Source

A Node may contain a TValue, a Table or a table array '[Table]'.

Instances

Eq Node 
Show Node 
ToJSON Node

ToJSON instances for the Node type that produce Aeson (JSON) in line with the TOML specification.

ToBsJSON Node

ToBsJSON instances for the Node type that produce Aeson (JSON) in line with BurntSushi's language agnostic TOML test suite.

data TValue Source

A TValue may contain any type of value that can put in a VArray.

Instances

Eq TValue 
Show TValue 
ToJSON TValue

ToJSON instances for the TValue type that produce Aeson (JSON) in line with the TOML specification.

ToBsJSON TValue

ToBsJSON instances for the TValue type that produce Aeson (JSON) in line with BurntSushi's language agnostic TOML test suite.

As seen in this function, BurntSushi's JSON encoding explicitly specifies the types of the values.

emptyTable :: Table Source

Contruct an empty Table.

emptyNTable :: Node Source

Contruct an empty NTable.

insert :: ([Text], Node) -> Table -> Either Text Table Source

Inserts a table (Table) with name ('[Text]') which may be part of a table array (when Bool is True) into a Table. It may result in an error (Text) on the Left or a modified table on the Right.

merge :: Table -> Table -> Either [Text] Table Source

Merge two tables, resulting in an error when overlapping keys are found (Left will contian those keys). When no overlapping keys are found the result will contain the union of both tables in a Right.

commonInsertError :: Node -> [Text] -> Either Text Table Source

Convenience function to construct a common error message for the insert function.

Regular ToJSON instances

Special BurntSushi ToJSON type class and instances

class ToBsJSON a where Source

Type class for conversion to BurntSushi-style JSON.

BurntSushi has made a language agnostic test suite available that this library uses. This test suit expects that values are encoded as JSON objects with a 'type' and a value member.

Methods

toBsJSON :: a -> Value Source

Instances

ToBsJSON TValue

ToBsJSON instances for the TValue type that produce Aeson (JSON) in line with BurntSushi's language agnostic TOML test suite.

As seen in this function, BurntSushi's JSON encoding explicitly specifies the types of the values.

ToBsJSON Node

ToBsJSON instances for the Node type that produce Aeson (JSON) in line with BurntSushi's language agnostic TOML test suite.

ToBsJSON a => ToBsJSON [a]

Provide a toBsJSON instance to the NTArray.

ToBsJSON v => ToBsJSON (HashMap Text v)

Provide a toBsJSON instance to the NTable.