Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains a map data structure, that preserves insertion order. Some definitions conflict with functions from prelude, so this module should probably be imported qualified.
Synopsis
- data OrderedMap v
- elems :: forall v. OrderedMap v -> [v]
- empty :: forall v. OrderedMap v
- insert :: Semigroup v => Text -> v -> OrderedMap v -> OrderedMap v
- foldlWithKey' :: forall v a. (a -> Text -> v -> a) -> a -> OrderedMap v -> a
- keys :: forall v. OrderedMap v -> [Text]
- lookup :: forall v. Text -> OrderedMap v -> Maybe v
- replace :: Text -> v -> OrderedMap v -> OrderedMap v
- singleton :: forall v. Text -> v -> OrderedMap v
- size :: forall v. OrderedMap v -> Int
- toList :: forall v. OrderedMap v -> [(Text, v)]
- traverseMaybe :: Applicative f => forall a. (a -> f (Maybe b)) -> OrderedMap a -> f (OrderedMap b)
Documentation
data OrderedMap v Source #
This map associates values with the given text keys. Insertion order is
preserved. When inserting a value with a key, that is already available in
the map, the existing value isn't overridden, but combined with the new value
using its Semigroup
instance.
Internally this map uses an array with keys to preserve the order and an unorded map with key-value pairs.
Instances
elems :: forall v. OrderedMap v -> [v] Source #
Returns a list with all elements in this map.
empty :: forall v. OrderedMap v Source #
Constructs an empty map.
insert :: Semigroup v => Text -> v -> OrderedMap v -> OrderedMap v Source #
Associates the specified value with the specified key in this map. If this map previously contained a mapping for the key, the existing and new values are combined.
foldlWithKey' :: forall v a. (a -> Text -> v -> a) -> a -> OrderedMap v -> a Source #
Reduces this map by applying a binary operator from left to right to all elements, using the given starting value.
keys :: forall v. OrderedMap v -> [Text] Source #
Returns a list with all keys in this map.
replace :: Text -> v -> OrderedMap v -> OrderedMap v Source #
Associates the specified value with the specified key in this map. If this map previously contained a mapping for the key, the existing value is replaced by the new one.
singleton :: forall v. Text -> v -> OrderedMap v Source #
Constructs a map with a single element.
size :: forall v. OrderedMap v -> Int Source #
Gives the size of this map, i.e. number of elements in it.
toList :: forall v. OrderedMap v -> [(Text, v)] Source #
Converts this map to the list of key-value pairs.
traverseMaybe :: Applicative f => forall a. (a -> f (Maybe b)) -> OrderedMap a -> f (OrderedMap b) Source #
Traverse over the elements and collect the Just
results.