Toml.Codec.Code

tomland-1.3.3.3: Bidirectional TOML serialization

Copyright | (c) 2018-2022 Kowainik
License | MPL-2.0
Maintainer | Kowainik <xrom.xkov@gmail.com>
Stability | Stable
Portability | Portable
Safe Haskell | None
Language | Haskell2010

Toml.Codec.Code

Contents

- Decode
- Encode
- Run

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 :: TomlCodec a -> Text -> Either [TomlDecodeError] a
- decodeExact :: TomlCodec a -> Text -> Either [TomlDecodeError] a
- decodeValidation :: TomlCodec a -> Text -> Validation [TomlDecodeError] a
- decodeFileEither :: forall a m. MonadIO m => TomlCodec a -> FilePath -> m (Either [TomlDecodeError] a)
- decodeFile :: forall a m. MonadIO m => TomlCodec a -> FilePath -> m a
- decodeFileExact :: forall a m. MonadIO m => TomlCodec a -> FilePath -> m (Either [TomlDecodeError] a)
- encode :: TomlCodec a -> a -> Text
- encodeToFile :: forall a m. MonadIO m => TomlCodec a -> FilePath -> a -> m Text
- runTomlCodec :: TomlCodec a -> TOML -> Validation [TomlDecodeError] a
- execTomlCodec :: TomlCodec a -> a -> TOML

# Decode

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

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

Since: 0.0.0

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

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 #

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) #

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 #

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) #

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 #

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 #

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 #

Convert toml into user data type.

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

Runs `codecWrite` of `TomlCodec` and returns intermediate TOML AST.