Safe Haskell | None |
---|---|
Language | Haskell2010 |
Implementation of partial bidirectional mapping as a data type.
Synopsis
- data BiMap a b = BiMap {}
- invert :: BiMap a b -> BiMap b a
- iso :: (a -> b) -> (b -> a) -> BiMap a b
- prism :: (object -> Maybe field) -> (field -> object) -> BiMap object field
- matchValueForward :: BiMap AnyValue a -> Value t -> Maybe a
- mkAnyValueBiMap :: (forall t. Value t -> Maybe a) -> (a -> Value tag) -> BiMap AnyValue a
- _Array :: BiMap AnyValue a -> BiMap AnyValue [a]
- _Bool :: BiMap AnyValue Bool
- _Double :: BiMap AnyValue Double
- _Integer :: BiMap AnyValue Integer
- _String :: BiMap AnyValue String
- _Text :: BiMap AnyValue Text
- _TextToString :: BiMap Text String
- _Left :: BiMap l (Either l r)
- _Right :: BiMap r (Either l r)
- toMArray :: [AnyValue] -> Maybe (Value TArray)
BiMap idea
Partial bidirectional isomorphism. BiMap a b
contains two function:
a -> Maybe b
b -> Maybe a
prism :: (object -> Maybe field) -> (field -> object) -> 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 AnyValue a Source #
Creates prism for AnyValue
.