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.BiMap.Conversion

Contents

- Primitive
  - Boolean
  - Integral
  - Floating
  - Text
- Time
- Arrays
- Coerce
- Custom
- `Key`s
- General purpose
- Internal helpers

Description

Implementations of `BiMap` for specific Haskell types and TOML values. Usually, you use codecs from the Toml.Codec.Combinator module. You may need to use these `BiMap`s instead of codecs in the following situations:

1. When using `arrayOf` combinator (or similar).
2. When using `tableMap` combinator (for keys).
3. When implementing custom `BiMap` for your types.

Since: 1.3.0.0

Synopsis

- _Bool :: TomlBiMap Bool AnyValue
- _Int :: TomlBiMap Int AnyValue
- _Word :: TomlBiMap Word AnyValue
- _Word8 :: TomlBiMap Word8 AnyValue
- _Integer :: TomlBiMap Integer AnyValue
- _Natural :: TomlBiMap Natural AnyValue
- _Double :: TomlBiMap Double AnyValue
- _Float :: TomlBiMap Float AnyValue
- _Text :: TomlBiMap Text AnyValue
- _LText :: TomlBiMap Text AnyValue
- _ByteString :: TomlBiMap ByteString AnyValue
- _LByteString :: TomlBiMap ByteString AnyValue
- _String :: TomlBiMap String AnyValue
- _ZonedTime :: TomlBiMap ZonedTime AnyValue
- _LocalTime :: TomlBiMap LocalTime AnyValue
- _Day :: TomlBiMap Day AnyValue
- _TimeOfDay :: TomlBiMap TimeOfDay AnyValue
- _Array :: TomlBiMap a AnyValue -> TomlBiMap [a] AnyValue
- _NonEmpty :: TomlBiMap a AnyValue -> TomlBiMap (NonEmpty a) AnyValue
- _Set :: Ord a => TomlBiMap a AnyValue -> TomlBiMap (Set a) AnyValue
- _HashSet :: Hashable a => TomlBiMap a AnyValue -> TomlBiMap (HashSet a) AnyValue
- _IntSet :: TomlBiMap IntSet AnyValue
- _ByteStringArray :: TomlBiMap ByteString AnyValue
- _LByteStringArray :: TomlBiMap ByteString AnyValue
- _Coerce :: Coercible a b => TomlBiMap a AnyValue -> TomlBiMap b AnyValue
- _EnumBounded :: (Show a, Enum a, Bounded a) => TomlBiMap a AnyValue
- _Read :: (Show a, Read a) => TomlBiMap a AnyValue
- _TextBy :: (a -> Text) -> (Text -> Either Text a) -> TomlBiMap a AnyValue
- _Validate :: (a -> Either Text a) -> TomlBiMap a AnyValue -> TomlBiMap a AnyValue
- _Hardcoded :: (Show a, Eq a) => a -> TomlBiMap a a
- _KeyText :: TomlBiMap Key Text
- _KeyString :: TomlBiMap Key String
- _KeyInt :: TomlBiMap Key Int
- _Just :: Show r => TomlBiMap (Maybe r) r
- _Left :: (Show l, Show r) => TomlBiMap (Either l r) l
- _Right :: (Show l, Show r) => TomlBiMap (Either l r) r
- _LTextText :: BiMap e Text Text
- _NaturalInteger :: TomlBiMap Natural Integer
- _NonEmptyList :: TomlBiMap (NonEmpty a) [a]
- _StringText :: BiMap e String Text
- _ReadString :: (Show a, Read a) => TomlBiMap a String
- _BoundedInteger :: (Integral a, Bounded a, Show a) => TomlBiMap a Integer
- _EnumBoundedText :: (Show a, Enum a, Bounded a) => TomlBiMap a Text
- _ByteStringText :: TomlBiMap ByteString Text
- _LByteStringText :: TomlBiMap ByteString Text

# Primitive

## Boolean

_Bool :: TomlBiMap Bool AnyValue #

`Bool` `BiMap` for `AnyValue`. Usually used as the `bool` combinator.

Since: 0.4.0

## Integral

_Int :: TomlBiMap Int AnyValue #

`Int` `BiMap` for `AnyValue`. Usually used as the `int` combinator.

Since: 0.5.0

_Word :: TomlBiMap Word AnyValue #

`Word` `BiMap` for `AnyValue`. Usually used as the `word` combinator.

Since: 0.5.0

_Word8 :: TomlBiMap Word8 AnyValue #

`Word8` `BiMap` for `AnyValue`. Usually used as the `word8` combinator.

Since: 1.2.0.0

_Integer :: TomlBiMap Integer AnyValue #

`Integer` `BiMap` for `AnyValue`. Usually used as the `integer` combinator.

Since: 0.4.0

_Natural :: TomlBiMap Natural AnyValue #

`Natural` `BiMap` for `AnyValue`. Usually used as the `natural` combinator.

Since: 0.5.0

## Floating

_Double :: TomlBiMap Double AnyValue #

`Double` `BiMap` for `AnyValue`. Usually used as the `double` combinator.

Since: 0.4.0

_Float :: TomlBiMap Float AnyValue #

`Float` `BiMap` for `AnyValue`. Usually used as the `float` combinator.

Since: 0.5.0

## Text

_Text :: TomlBiMap Text AnyValue #

`Text` `BiMap` for `AnyValue`. Usually used as the `text` combinator.

Since: 0.4.0

_LText :: TomlBiMap Text AnyValue #

`Text` `BiMap` for `AnyValue`. Usually used as the `lazyText` combinator.

Since: 1.0.0

_ByteString :: TomlBiMap ByteString AnyValue #

UTF-8 encoded `ByteString` `BiMap` for `AnyValue`. Usually used as the `byteString` combinator.

Since: 0.5.0

_LByteString :: TomlBiMap ByteString AnyValue #

UTF-8 encoded lazy `ByteString` `BiMap` for `AnyValue`. Usually used as the `lazyByteString` combinator.

Since: 0.5.0

_String :: TomlBiMap String AnyValue #

`String` `BiMap` for `AnyValue`. Usually used as the `string` combinator.

Since: 0.4.0

# Time

_ZonedTime :: TomlBiMap ZonedTime AnyValue #

`ZonedTime` bimap for `AnyValue`. Usually used as the `zonedTime` combinator.

Since: 0.5.0

_LocalTime :: TomlBiMap LocalTime AnyValue #

`LocalTime` bimap for `AnyValue`. Usually used as the `localTime` combinator.

Since: 0.5.0

_Day :: TomlBiMap Day AnyValue #

`Day` `BiMap` for `AnyValue`. Usually used as the `day` combinator.

Since: 0.5.0

_TimeOfDay :: TomlBiMap TimeOfDay AnyValue #

`TimeOfDay` `BiMap` for `AnyValue`. Usually used as the `timeOfDay` combinator.

Since: 0.5.0

# Arrays

_Array :: TomlBiMap a AnyValue -> TomlBiMap [a] AnyValue #

Takes a `BiMap` of a value and returns a `BiMap` for a list of values and `AnyValue` as an array. Usually used as the `arrayOf` combinator.

Since: 0.4.0

_NonEmpty :: TomlBiMap a AnyValue -> TomlBiMap (NonEmpty a) AnyValue #

Takes a `BiMap` of a value and returns a `BiMap` for a `NonEmpty` list of values and `AnyValue` as an array. Usually used as the `arrayNonEmptyOf` combinator.

Since: 0.5.0

_Set :: Ord a => TomlBiMap a AnyValue -> TomlBiMap (Set a) AnyValue #

Takes a `BiMap` of a value and returns a `BiMap` for a `Set` of values and `AnyValue` as an array. Usually used as the `arraySetOf` combinator.

Since: 0.5.0

_HashSet :: Hashable a => TomlBiMap a AnyValue -> TomlBiMap (HashSet a) AnyValue #

Takes a `BiMap` of a value and returns a `BiMap` for a `HashSet` of values and `AnyValue` as an array. Usually used as the `arrayHashSetOf` combinator.

Since: 0.5.0

_IntSet :: TomlBiMap IntSet AnyValue #

`IntSet` bimap for `AnyValue`. Usually used as the `arrayIntSet` combinator.

Since: 0.5.0

_ByteStringArray :: TomlBiMap ByteString AnyValue #

`ByteString` `BiMap` for `AnyValue` encoded as a list of bytes (non-negative integers between 0 and 255). Usually used as the `byteStringArray` combinator.

Since: 1.2.0.0

_LByteStringArray :: TomlBiMap ByteString AnyValue #

Lazy `ByteString` `BiMap` for `AnyValue` encoded as a list of bytes (non-negative integers between 0 and 255). Usually used as `lazyByteStringArray` combinator.

Since: 1.2.0.0

# Coerce

_Coerce :: Coercible a b => TomlBiMap a AnyValue -> TomlBiMap b AnyValue #

`BiMap` for `Coercible` values. It takes a `TomlBiMap` for `a` type and returns a `TomlBiMap` `b` if these types are coercible.

It is supposed to be used to ease the work with `newtypes`.

E.g.

    newtype Foo = Foo
        { unFoo :: Int
        }

    fooBiMap :: TomlBiMap Foo AnyValue
    fooBiMap = _Coerce _Int

Since: 1.3.0.0

# Custom

_EnumBounded :: (Show a, Enum a, Bounded a) => TomlBiMap a AnyValue #

`BiMap` for nullary sum data types (enumerations) with `Show`, `Enum` and `Bounded` instances. Usually used as the `enumBounded` combinator.

Since: 1.1.0.0

_Read :: (Show a, Read a) => TomlBiMap a AnyValue #

`BiMap` for `AnyValue` and values with a `Read` and `Show` instances. Usually used as the `read` combinator.

Since: 0.5.0

_TextBy #

Arguments

:: (a -> Text) | `show` function for `a`
-> (Text -> Either Text a) | Parser of `a` from `Text`
-> TomlBiMap a AnyValue |

Creates `BiMap` for `Text` to `AnyValue` with custom functions. Usually used as the `textBy` combinator.

Since: 0.5.0

_Validate :: (a -> Either Text a) -> TomlBiMap a AnyValue -> TomlBiMap a AnyValue #

By the given `BiMap` validates it with the given predicate that returns `Either` the value, if the validation is successful, or the `Text` of the error that should be returned in case of validation failure.

Usually used as the `validate` or `validateIf` combinator.

Since: 1.3.0.0

_Hardcoded :: (Show a, Eq a) => a -> TomlBiMap a a #

`BiMap` for hardcoded values. It returns the same value in case of success and `ArbitraryError` in other case.

Since: 1.3.2.0

# `Key`s

_KeyText :: TomlBiMap Key Text #

Bidirectional converter between `Key` and `Text`. Usually used as an argument for `tableMap`.

Since: 1.3.0.0

_KeyString :: TomlBiMap Key String #

Bidirectional converter between `Key` and `String`. Usually used as an argument for `tableMap`.

Since: 1.3.0.0

_KeyInt :: TomlBiMap Key Int #

Bidirectional converter between `Key` and `Int`. Usually used as an argument for `tableIntMap`.

Since: 1.3.0.0

# General purpose

_Just :: Show r => TomlBiMap (Maybe r) r #

`BiMap` for `Maybe` and its `Just` part.

Since: 0.5.0

_Left :: (Show l, Show r) => TomlBiMap (Either l r) l #

`BiMap` for `Either` and its `Left` part.

Since: 0.4.0

_Right :: (Show l, Show r) => TomlBiMap (Either l r) r #

`BiMap` for `Either` and its `Right` part.

Since: 0.4.0

# Internal helpers

_LTextText :: BiMap e Text Text #

Helper bimap for `Text` and `Text`.

Since: 1.0.0

_NaturalInteger :: TomlBiMap Natural Integer #

Helper `BiMap` for `Natural` and `Integer`.

Since: 0.5.0

_NonEmptyList :: TomlBiMap (NonEmpty a) [a] #

Helper `BiMap` for lists and `NonEmpty`.

Since: 1.3.0.0

_StringText :: BiMap e String Text #

Helper `BiMap` for `String` and `Text`.

Since: 0.4.0

_ReadString :: (Show a, Read a) => TomlBiMap a String #

Helper `BiMap` for `String` and types with `Read` and `Show` instances.

Since: 0.5.0

_BoundedInteger :: (Integral a, Bounded a, Show a) => TomlBiMap a Integer #

Helper `BiMap` for `Integer` and integral, bounded values.

Since: 0.5.0

_EnumBoundedText :: (Show a, Enum a, Bounded a) => TomlBiMap a Text #

Helper `BiMap` for `_EnumBounded` and `Text`.

Since: 1.1.0.0

_ByteStringText :: TomlBiMap ByteString Text #

Helper `BiMap` for `Text` and strict `ByteString`

Since: 0.5.0

_LByteStringText :: TomlBiMap ByteString Text #

Helper `BiMap` for `Text` and lazy `ByteString`.

Since: 0.5.0