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

Toml.Codec.BiMap.Conversion

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 BiMaps 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

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

Keys

_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

_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