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.Combinator.Common

Description

This module implements common utilities for writing custom codecs without diving into internal implementation details. Most of the time you don't need to implement your own codecs and can reuse existing ones. But if you need something that library doesn't provide, you can find functions in this module useful.

Since: 1.3.0.0

Synopsis

- match :: TomlBiMap a AnyValue -> Key -> TomlCodec a
- whenLeftBiMapError :: Key -> Either TomlBiMapError a -> (a -> Validation [TomlDecodeError] b) -> Validation [TomlDecodeError] b

# Documentation

match :: TomlBiMap a AnyValue -> Key -> TomlCodec a #

General function to create bidirectional converters for key-value pairs. In order to use this function you need to create `TomlBiMap` for your type and `AnyValue`:

    _MyType :: TomlBiMap MyType AnyValue

And then you can create codec for your type using `match` function:

    myType :: Key -> TomlCodec MyType
    myType = match _MyType

Since: 0.4.0

whenLeftBiMapError :: Key -> Either TomlBiMapError a -> (a -> Validation [TomlDecodeError] b) -> Validation [TomlDecodeError] b #

Throw error on `Left`, or perform a given action with `Right`.

Since: 1.3.0.0