tomland-0.5.0: Bidirectional TOML parser

Safe HaskellNone
LanguageHaskell2010

Toml.BiMap

Contents

Description

Implementation of partial bidirectional mapping as a data type.

Synopsis

BiMap idea

data BiMap a b Source #

Partial bidirectional isomorphism. BiMap a b contains two function:

  1. a -> Maybe b
  2. b -> Maybe a

Constructors

BiMap 

Fields

Instances
Category BiMap Source # 
Instance details

Defined in Toml.BiMap

Methods

id :: BiMap a a #

(.) :: BiMap b c -> BiMap a b -> BiMap a c #

invert :: BiMap a b -> BiMap b a Source #

Inverts bidirectional mapping.

iso :: (a -> b) -> (b -> a) -> BiMap a b Source #

Creates BiMap from isomorphism.

prism :: (field -> object) -> (object -> Maybe field) -> BiMap object field Source #

Creates BiMap from prism-like pair of functions.

Helpers for BiMap and AnyValue

mkAnyValueBiMap :: (forall t. Value t -> Maybe a) -> (a -> Value tag) -> BiMap a AnyValue Source #

Creates prism for AnyValue.

_TextBy :: (a -> Text) -> (Text -> Maybe a) -> BiMap a AnyValue Source #

Creates bimap for Value to AnyValue with custom functions

_StringText :: BiMap String Text Source #

Helper bimap for String and Value.

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

Helper bimap for String and types with Read and Show instances.

_BoundedInteger :: (Integral a, Bounded a) => BiMap a Integer Source #

Helper bimap for Value and integral, bounded values.

Some predefined bi mappings

_Array :: BiMap a AnyValue -> BiMap [a] AnyValue Source #

Takes a bimap of a value and returns a bimap of a list of values and Anything as an array. Usually used with arrayOf combinator.

_Bool :: BiMap Bool AnyValue Source #

Value bimap for AnyValue. Usually used with bool combinator.

_Double :: BiMap Double AnyValue Source #

Value bimap for AnyValue. Usually used with double combinator.

_Integer :: BiMap Integer AnyValue Source #

Value bimap for AnyValue. Usually used with integer combinator.

_Text :: BiMap Text AnyValue Source #

Value bimap for AnyValue. Usually used with text combinator.

_ZonedTime :: BiMap ZonedTime AnyValue Source #

Zoned time bimap for AnyValue. Usually used with zonedTime combinator.

_LocalTime :: BiMap LocalTime AnyValue Source #

Local time bimap for AnyValue. Usually used with localTime combinator.

_Day :: BiMap Day AnyValue Source #

Day bimap for AnyValue. Usually used with day combinator.

_TimeOfDay :: BiMap TimeOfDay AnyValue Source #

Time of day bimap for AnyValue. Usually used with timeOfDay combinator.

_String :: BiMap String AnyValue Source #

String bimap for AnyValue. Usually used with string combinator.

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

Bimap for AnyValue and values with a Read and Show instance. Usually used with read combinator.

_Natural :: BiMap Natural AnyValue Source #

Natural bimap for AnyValue. Usually used with natural combinator.

_Word :: BiMap Word AnyValue Source #

Word bimap for AnyValue. Usually used with word combinator.

_Int :: BiMap Int AnyValue Source #

Int bimap for AnyValue. Usually used with int combinator.

_Float :: BiMap Float AnyValue Source #

Float bimap for AnyValue. Usually used with float combinator.

_ByteString :: BiMap ByteString AnyValue Source #

ByteString bimap for AnyValue. Usually used with byteString combinator.

_LByteString :: BiMap ByteString AnyValue Source #

Lazy ByteString bimap for AnyValue. Usually used with lazyByteString combinator.

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

Takes a bimap of a value and returns a bimap of a set of values and Anything as an array. Usually used with setOf combinator.

_IntSet :: BiMap IntSet AnyValue Source #

Bimap of IntSet and Anything as an array. Usually used with intSet combinator.

_HashSet :: (Eq a, Hashable a) => BiMap a AnyValue -> BiMap (HashSet a) AnyValue Source #

Takes a bimap of a value and returns a bimap of a has set of values and Anything as an array. Usually used with hashSetOf combinator.

_NonEmpty :: BiMap a AnyValue -> BiMap (NonEmpty a) AnyValue Source #

Takes a bimap of a value and returns a bimap of a non-empty list of values and Anything as an array. Usually used with nonEmptyOf combinator.

_Left :: BiMap (Either l r) l Source #

Bimap for Either and its left type

_Right :: BiMap (Either l r) r Source #

Bimap for Either and its right type

_Just :: BiMap (Maybe a) a Source #

Bimap for Maybe

Useful utility functions

toMArray :: [AnyValue] -> Maybe (Value TArray) Source #

Function for creating Array from list of AnyValue.