Copyright | (c) 2018-2022 Kowainik |
---|---|
License | MPL-2.0 |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Stability | Stable |
Portability | Portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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 :: forall a. TomlBiMap a AnyValue -> Key -> TomlCodec a
- whenLeftBiMapError :: Key -> Either TomlBiMapError a -> (a -> Validation [TomlDecodeError] b) -> Validation [TomlDecodeError] b
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
MyTypeAnyValue
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 #