tomland-0.1.0: TOML parser

Safe HaskellNone
LanguageHaskell2010

Toml.Bi.Combinators

Contents

Description

Contains TOML-specific combinators for converting between TOML and user data types.

Synopsis

Types

type BiToml a = Bi Env St a Source #

Specialied Bi type alias for Toml monad. Keeps TOML object either as environment or state.

type Env = ExceptT EncodeException (Reader TOML) Source #

Immutable environment for Toml conversion. This is r type variable in Bijection data type.

type St = ExceptT DecodeException (State TOML) Source #

Mutable context for Toml conversion. This is w type variable in Bijection data type.

Exceptions

data EncodeException Source #

Type of exception for converting from Toml to user custom data type.

data DecodeException Source #

Write exception for convertion to Toml from user custom data type.

Encode/Decode

encode :: BiToml a -> Text -> Either EncodeException a Source #

Convert textual representation of toml into user data type.

decode :: BiToml a -> a -> Either DecodeException Text Source #

Convert object to textual representation.

unsafeDecode :: BiToml a -> a -> Text Source #

Unsafe version of decode function if you're sure that you decoding of structure is correct.

Converters

bijectionMaker Source #

Arguments

:: Text

Name of expected type

-> (forall f. Value f -> Maybe a)

How to convert from AnyValue to a

-> (a -> Value t)

Convert a to Anyvale

-> Key

Key of the value

-> BiToml a 

General function to create bidirectional converters for values.

dimapNum :: forall n r w. (Integral n, Functor r, Functor w) => Bi r w Integer -> Bi r w n Source #

Helper dimapper to turn integer parser into parser for Int, Natural, Word, etc.

Toml parsers

bool :: Key -> BiToml Bool Source #

Parser for boolean values.

int :: Key -> BiToml Int Source #

Parser for integer values.

integer :: Key -> BiToml Integer Source #

Parser for integer values.

double :: Key -> BiToml Double Source #

Parser for floating values.

str :: Key -> BiToml Text Source #

Parser for string values.

arrayOf :: forall a t. Valuer t a -> Key -> BiToml [a] Source #

Parser for array of values. Takes converter for single array element and returns list of values.

maybeP :: forall a. (Key -> BiToml a) -> Key -> BiToml (Maybe a) Source #

Bidirectional converter for Maybe smth values.

Value parsers

data Valuer (tag :: ValueType) a Source #

This data type describes how to convert value of type a into and from Value.

Constructors

Valuer 

Fields

boolV :: Valuer TBool Bool Source #

Bool parser for array element. Use with arrayOf parser.

integerV :: Valuer TInt Integer Source #

Int parser for array element. Use with arrayOf parser.

doubleV :: Valuer TFloat Double Source #

Double parser for array element. Use with arrayOf parser.

strV :: Valuer TString Text Source #

Text parser for array element. Use with arrayOf parser.

arrV :: forall a t. Valuer t a -> Valuer TArray [a] Source #

Parser for array element which is an array itself. Use with arrayOf parser.