tomland-0.4.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 :: (object -> Maybe field) -> (field -> object) -> BiMap object field Source #

Creates BiMap from prism-like pair of functions.

Helpers for BiMap and AnyValue

matchValueForward :: BiMap AnyValue a -> Value t -> Maybe a Source #

Allows to match against given Value using provided prism for AnyValue.

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

Creates prism for AnyValue.

Some predefined bi mappings

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

Array bimap for AnyValue. Usually used with arrayOf combinator.

_Bool :: BiMap AnyValue Bool Source #

Bool bimap for AnyValue. Usually used with arrayOf combinator.

_Double :: BiMap AnyValue Double Source #

Double bimap for AnyValue. Usually used with arrayOf combinator.

_Integer :: BiMap AnyValue Integer Source #

Integer bimap for AnyValue. Usually used with arrayOf combinator.

_Text :: BiMap AnyValue Text Source #

Text bimap for AnyValue. Usually used with arrayOf combinator.

Useful utility functions

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

Function for creating Array from list of AnyValue.