DA.TextMap
DA.TextMap
TextMap - A map is an associative array data type composed of a collection of key/value pairs such that, each possible key appears at most once in the collection.
Functions
fromListCreate a map from a list of key/value pairs.
fromListWithL: (a -> a -> a) -> [(Text, a)] -> TextMap a
Create a map from a list of key/value pairs with a combining function. The combining function is only used when a key appears multiple times in the list and it takes two arguments: the first one is the new value being inserted at that key and the second one is the value accumulated so far at that key. Examples:
>>> fromListWithL (++) [("A", [1]), ("A", [2]), ("B", [2]), ("B", [1]), ("A", [3])]
fromList [("A", [3, 2, 1]), ("B", [1, 2])]
>>> fromListWithL (++) [] == (empty : TextMap [Int])
True
: (a -> a -> a) -> [(Text, a)] -> TextMap a
Create a map from a list of key/value pairs like fromListWithL
with the combining function flipped. Examples:
>>> fromListWithR (++) [("A", [1]), ("A", [2]), ("B", [2]), ("B", [1]), ("A", [3])]
fromList [("A", [1, 2, 3]), ("B", [2, 1])]
>>> fromListWithR (++) [] == (empty : TextMap [Int])
True
: (a -> a -> a) -> [(Text, a)] -> TextMap a
Warning
DEPRECATED:
Convert the map to a list of key/value pairs where the keys are in ascending order.
empty: TextMap a
The empty map.
sizeNumber of elements in the map.
nullIs the map empty?
lookup: Text -> TextMap a -> Optional a
Lookup the value at a key in the map.
memberIs the key a member of the map?
filter: (v -> Bool) -> TextMap v -> TextMap v
Filter the TextMap using a predicate: keep only the entries where the
value satisfies the predicate.
: (Text -> v -> Bool) -> TextMap v -> TextMap v
Filter the TextMap using a predicate: keep only the entries which
satisfy the predicate.
: Text -> TextMap a -> TextMap a
Delete a key and its value from the map. When the key is not a member of the map, the original map is returned.
singletonCreate a singleton map.
insert: Text -> a -> TextMap a -> TextMap a
Insert a new key/value pair in the map. If the key is already present in the map, the associated value is replaced with the supplied value.
insertWith: (v -> v -> v) -> Text -> v -> TextMap v -> TextMap v
Insert a new key/value pair in the map. If the key is already
present in the map, it is combined with the previous value using the given function
f new_value old_value.
: TextMap a -> TextMap a -> TextMap a
The union of two maps, preferring the first map when equal keys are encountered.
merge: (Text -> a -> Optional c) -> (Text -> b -> Optional c) -> (Text -> a -> b -> Optional c) -> TextMap a -> TextMap b -> TextMap c
Merge two maps. merge f g h x y applies f to all key/value pairs
whose key only appears in x, g to all pairs whose key only appears
in y and h to all pairs whose key appears in both x and y.
In the end, all pairs yielding Some are collected as the result.