Module DA.Next.Map

Map - 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.

Typeclasses

class Eq k => MapKey k where

A class for types that can be used as keys for the Map type. All keys k must satisfy keyFromText (keyToText k) == k.

keyToText

: k -> Text

Turn a key into its textual representation. This function must be injective.

keyFromText

: Text -> k

Recover a key from its textual representation. keyFromText x is allowed to fail whenever there is no key k with keyToText k == x. Whenever such a k does exist, then it must satisfy keyFromText x == k.

instance MapKey Party

instance MapKey Decimal

instance MapKey Int

instance MapKey Text

Data Types

data Map k v

A Map k v is an associative array data type composed of a collection of key/value pairs of key type k and value type v such that each possible key appears at most once in the collection.

instance Foldable (Map k)

instance MapKey k => Monoid (Map k v)

instance MapKey k => Semigroup (Map k v)

instance MapKey k => Traversable (Map k)

instance MapKey k => Functor (Map k)

instance Eq v => Eq (Map k v)

instance Ord v => Ord (Map k v)

instance (MapKey k, Show k, Show v) => Show (Map k v)

Functions

fromList

: MapKey k => [(k, v)] -> Map k v

Create a map from a list of key/value pairs.

fromListWith

: MapKey k => (v -> v -> v) -> [(k, v)] -> Map k v

Create a map from a list of key/value pairs with a combining function. Examples:

fromListWith (<>) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] == fromList [(3, "ba"), (5, "abc")]
fromListWith (<>) [] == (empty : Map Int Text)
toList

: MapKey k => Map k v -> [(k, v)]

Convert the map to a list of key/value pairs where the keys are in ascending order of their textual representation.

fromTextMap

: TextMap v -> Map Text v

Create a Map from a TextMap.

toTextMap

: MapKey k => Map k v -> TextMap v

Convert a Map into a TextMap.

empty

: Map k v

The empty map.

size

: Map k v -> Int

Number of elements in the map.

null

: Map k v -> Bool

Is the map empty?

lookup

: MapKey k => k -> Map k v -> Optional v

Lookup the value at a key in the map.

member

: MapKey k => k -> Map k v -> Bool

Is the key a member of the map?

filter

: MapKey k => (v -> Bool) -> Map k v -> Map k v

Filter the Map using a predicate: keep only the entries where the value satisfies the predicate.

filterWithKey

: MapKey k => (k -> v -> Bool) -> Map k v -> Map k v

Filter the Map using a predicate: keep only the entries which satisfy the predicate.

delete

: MapKey k => k -> Map k v -> Map k v

Delete a key and its value from the map. When the key is not a member of the map, the original map is returned.

insert

: MapKey k => k -> v -> Map k v -> Map k v

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.

union

: MapKey k => Map k v -> Map k v -> Map k v

The union of two maps, preferring the first map when equal keys are encountered.

merge

: MapKey k => (k -> a -> Optional c) -> (k -> b -> Optional c) -> (k -> a -> b -> Optional c) -> Map k a -> Map k b -> Map k 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.