tomland-1.0.0: Bidirectional TOML serialization

Safe HaskellNone
LanguageHaskell2010

Toml.Bi.Code

Contents

Description

Coding functions like decode and encode. Also contains specialization of Codec for TOML.

Synopsis

Types

type TomlCodec a = BiCodec Env St a Source #

Specialied BiCodec type alias for bidirectional TOML serialization. Keeps TOML object as both environment and state.

type Env = ExceptT DecodeException (Reader TOML) Source #

Immutable environment for TOML conversion. This is r type variable in Codec data type.

type St = MaybeT (State TOML) Source #

Mutable context for TOML conversion. This is w type variable in Codec data type.

MaybeT (State TOML) a
    = State TOML (Maybe a)
    = TOML -> (Maybe a, TOML)

Exceptions

data DecodeException Source #

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

Constructors

TrivialError 
BiMapError TomlBiMapError 
KeyNotFound Key

No such key

TableNotFound Key

No such table

TypeMismatch Key Text TValue

Expected type vs actual type

ParseError ParseException

Exception during parsing

Instances
Eq DecodeException Source # 
Instance details

Defined in Toml.Bi.Code

Show DecodeException Source # 
Instance details

Defined in Toml.Bi.Code

Generic DecodeException Source # 
Instance details

Defined in Toml.Bi.Code

Associated Types

type Rep DecodeException :: Type -> Type #

Semigroup DecodeException Source # 
Instance details

Defined in Toml.Bi.Code

Monoid DecodeException Source # 
Instance details

Defined in Toml.Bi.Code

NFData DecodeException Source # 
Instance details

Defined in Toml.Bi.Code

Methods

rnf :: DecodeException -> () #

type Rep DecodeException Source # 
Instance details

Defined in Toml.Bi.Code

prettyException :: DecodeException -> Text Source #

Converts DecodeException into pretty human-readable text.

Encode/Decode

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

Convert textual representation of toml into user data type.

decodeFile :: MonadIO m => TomlCodec a -> FilePath -> m a Source #

Decode a value from a file. In case of parse errors, throws LoadTomlException.

runTomlCodec :: TomlCodec a -> TOML -> Either DecodeException a Source #

Convert toml into user data type.

encode :: TomlCodec a -> a -> Text Source #

Convert object to textual representation.

execTomlCodec :: TomlCodec a -> a -> TOML Source #

Runs codecWrite of TomlCodec and returns intermediate TOML AST.