tomland-1.3.3.2: Bidirectional TOML serialization
Copyright(c) 2018-2022 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
StabilityStable
PortabilityPortable
Safe HaskellSafe-Inferred
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 Source #

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

Since: 0.4.0

Integral

_Int :: TomlBiMap Int AnyValue Source #

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

Since: 0.5.0

_Word :: TomlBiMap Word AnyValue Source #

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

Since: 0.5.0

_Word8 :: TomlBiMap Word8 AnyValue Source #

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

Since: 1.2.0.0

_Integer :: TomlBiMap Integer AnyValue Source #

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

Since: 0.4.0

_Natural :: TomlBiMap Natural AnyValue Source #

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

Since: 0.5.0

Floating

_Double :: TomlBiMap Double AnyValue Source #

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

Since: 0.4.0

_Float :: TomlBiMap Float AnyValue Source #

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

Since: 0.5.0

Text

_Text :: TomlBiMap Text AnyValue Source #

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

Since: 0.4.0

_LText :: TomlBiMap Text AnyValue Source #

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

Since: 1.0.0

_ByteString :: TomlBiMap ByteString AnyValue Source #

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

Since: 0.5.0

_LByteString :: TomlBiMap ByteString AnyValue Source #

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

Since: 0.5.0

_String :: TomlBiMap String AnyValue Source #

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

Since: 0.4.0

Time

_ZonedTime :: TomlBiMap ZonedTime AnyValue Source #

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

Since: 0.5.0

_LocalTime :: TomlBiMap LocalTime AnyValue Source #

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

Since: 0.5.0

_Day :: TomlBiMap Day AnyValue Source #

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

Since: 0.5.0

_TimeOfDay :: TomlBiMap TimeOfDay AnyValue Source #

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

Since: 0.5.0

Arrays

_Array :: forall a. TomlBiMap a AnyValue -> TomlBiMap [a] AnyValue Source #

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

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

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 :: (Eq a, Hashable a) => TomlBiMap a AnyValue -> TomlBiMap (HashSet a) AnyValue Source #

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

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

Since: 0.5.0

_ByteStringArray :: TomlBiMap ByteString AnyValue Source #

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

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

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

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

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

Since: 0.5.0

_TextBy Source #

Arguments

:: forall a. (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 :: forall a. (a -> Either Text a) -> TomlBiMap a AnyValue -> TomlBiMap a AnyValue Source #

By the given BiMap validates it with the given predicate that returns Either the value, if the validation is successful, or the Value 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 :: forall a. (Show a, Eq a) => a -> TomlBiMap a a Source #

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

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

Since: 1.3.0.0

_KeyString :: TomlBiMap Key String Source #

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

Since: 1.3.0.0

_KeyInt :: TomlBiMap Key Int Source #

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

BiMap for Maybe and its Just part.

Since: 0.5.0

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

BiMap for Either and its Left part.

Since: 0.4.0

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

BiMap for Either and its Right part.

Since: 0.4.0

Internal helpers

_LTextText :: BiMap e Text Text Source #

Helper bimap for Text and Text.

Since: 1.0.0

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

Helper BiMap for lists and NonEmpty.

Since: 1.3.0.0

_StringText :: BiMap e String Text Source #

Helper BiMap for String and Text.

Since: 0.4.0

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

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

Helper BiMap for Integer and integral, bounded values.

Since: 0.5.0

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

Helper BiMap for _EnumBounded and Text.

Since: 1.1.0.0

_ByteStringText :: TomlBiMap ByteString Text Source #

Helper BiMap for Text and strict ByteString

Since: 0.5.0