tomland-1.3.3.0: Bidirectional TOML serialization
Copyright(c) 2018-2021 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
StabilityStable
PortabilityPortable
Safe HaskellNone
LanguageHaskell2010

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

Documentation

match :: forall a. TomlBiMap a AnyValue -> Key -> TomlCodec a Source #

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

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

Since: 1.3.0.0