tomland-1.3.3.2: Bidirectional TOML serialization
Copyright(c) 2018-2022 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
StabilityStable
PortabilityPortable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Toml.Codec.Code

Description

Conversion from textual representation of TOML values to the Haskell data types by the given TomlCodec.

This module includes coding functions like decode and encode.

Synopsis

Decode

decode :: TomlCodec a -> Text -> Either [TomlDecodeError] a Source #

Convert textual representation of TOML into user data type by the provided codec.

Since: 0.0.0

decodeExact :: TomlCodec a -> Text -> Either [TomlDecodeError] a Source #

Convert textual representation of TOML into user data type by the provided codec.

Unlike decode, this function returns NotExactDecode error in case if given TOML has redundant fields and other elements.

Since: 1.3.2.0

decodeValidation :: TomlCodec a -> Text -> Validation [TomlDecodeError] a Source #

Convert textual representation of TOML into user data type by the provided codec.

Since: 1.3.0.0

decodeFileEither :: forall a m. MonadIO m => TomlCodec a -> FilePath -> m (Either [TomlDecodeError] a) Source #

Similar to decode, but takes a path to a file with textual TOML values from which it decodes them with the provided codec.

Since: 1.3.0.0

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

Similar to decodeFileEither, throws LoadTomlException in case of parse errors (TomlDecodeError).

Since: 0.3.1

decodeFileExact :: forall a m. MonadIO m => TomlCodec a -> FilePath -> m (Either [TomlDecodeError] a) Source #

Similar to decodeExact, but takes a path to a file with textual TOML values from which it decodes them with the provided codec.

Since: 1.3.2.0

Encode

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

Convert data type to the textual representation of TOML values.

Since: 0.0.0

encodeToFile :: forall a m. MonadIO m => TomlCodec a -> FilePath -> a -> m Text Source #

Convert data type to the textual representation of TOML values. and write it info the given file.

Since: 1.3.0.0

Run

runTomlCodec :: TomlCodec a -> TOML -> Validation [TomlDecodeError] a Source #

Convert toml into user data type.

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

Runs codecWrite of TomlCodec and returns intermediate TOML AST.