Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
InsOrdHashMap
is like HashMap
, but it folds and traverses in insertion order.
This module interface mimics Data.HashMap.Strict, with some additions.
Synopsis
- data InsOrdHashMap k v
- empty :: InsOrdHashMap k v
- singleton :: Hashable k => k -> v -> InsOrdHashMap k v
- null :: InsOrdHashMap k v -> Bool
- size :: InsOrdHashMap k v -> Int
- member :: (Eq k, Hashable k) => k -> InsOrdHashMap k a -> Bool
- lookup :: (Eq k, Hashable k) => k -> InsOrdHashMap k v -> Maybe v
- lookupDefault :: (Eq k, Hashable k) => v -> k -> InsOrdHashMap k v -> v
- insert :: (Eq k, Hashable k) => k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v
- insertWith :: (Eq k, Hashable k) => (v -> v -> v) -> k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v
- delete :: (Eq k, Hashable k) => k -> InsOrdHashMap k v -> InsOrdHashMap k v
- adjust :: (Eq k, Hashable k) => (v -> v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v
- update :: (Eq k, Hashable k) => (a -> Maybe a) -> k -> InsOrdHashMap k a -> InsOrdHashMap k a
- alter :: (Eq k, Hashable k) => (Maybe v -> Maybe v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v
- union :: (Eq k, Hashable k) => InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
- unionWith :: (Eq k, Hashable k) => (v -> v -> v) -> InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
- unionWithKey :: (Eq k, Hashable k) => (k -> v -> v -> v) -> InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v
- unions :: (Eq k, Hashable k, Foldable f) => f (InsOrdHashMap k v) -> InsOrdHashMap k v
- map :: (v1 -> v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
- mapKeys :: (Eq k', Hashable k') => (k -> k') -> InsOrdHashMap k v -> InsOrdHashMap k' v
- traverseKeys :: (Eq k', Hashable k', Applicative f) => (k -> f k') -> InsOrdHashMap k v -> f (InsOrdHashMap k' v)
- mapWithKey :: (k -> v1 -> v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
- traverseWithKey :: Applicative f => (k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
- unorderedTraverse :: Applicative f => (a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
- unorderedTraverseWithKey :: Applicative f => (k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
- difference :: (Eq k, Hashable k) => InsOrdHashMap k v -> InsOrdHashMap k w -> InsOrdHashMap k v
- intersection :: (Eq k, Hashable k) => InsOrdHashMap k v -> InsOrdHashMap k w -> InsOrdHashMap k v
- intersectionWith :: (Eq k, Hashable k) => (v1 -> v2 -> v3) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3
- intersectionWithKey :: (Eq k, Hashable k) => (k -> v1 -> v2 -> v3) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3
- foldl' :: (a -> v -> a) -> a -> InsOrdHashMap k v -> a
- foldlWithKey' :: (a -> k -> v -> a) -> a -> InsOrdHashMap k v -> a
- foldr :: (v -> a -> a) -> a -> InsOrdHashMap k v -> a
- foldrWithKey :: (k -> v -> a -> a) -> a -> InsOrdHashMap k v -> a
- foldMapWithKey :: Monoid m => (k -> a -> m) -> InsOrdHashMap k a -> m
- unorderedFoldMap :: Monoid m => (a -> m) -> InsOrdHashMap k a -> m
- unorderedFoldMapWithKey :: Monoid m => (k -> a -> m) -> InsOrdHashMap k a -> m
- filter :: (v -> Bool) -> InsOrdHashMap k v -> InsOrdHashMap k v
- filterWithKey :: (k -> v -> Bool) -> InsOrdHashMap k v -> InsOrdHashMap k v
- mapMaybe :: (v1 -> Maybe v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
- mapMaybeWithKey :: (k -> v1 -> Maybe v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2
- keys :: InsOrdHashMap k v -> [k]
- elems :: InsOrdHashMap k v -> [v]
- toList :: InsOrdHashMap k v -> [(k, v)]
- toRevList :: InsOrdHashMap k v -> [(k, v)]
- fromList :: forall k v. (Eq k, Hashable k) => [(k, v)] -> InsOrdHashMap k v
- toHashMap :: InsOrdHashMap k v -> HashMap k v
- fromHashMap :: HashMap k v -> InsOrdHashMap k v
- hashMap :: Iso (InsOrdHashMap k a) (InsOrdHashMap k b) (HashMap k a) (HashMap k b)
- unorderedTraversal :: Traversal (InsOrdHashMap k a) (InsOrdHashMap k b) a b
- valid :: InsOrdHashMap k v -> Bool
Documentation
data InsOrdHashMap k v Source #
HashMap
which tries it's best to remember insertion order of elements.
Instances
Construction
empty :: InsOrdHashMap k v Source #
singleton :: Hashable k => k -> v -> InsOrdHashMap k v Source #
Basic interface
null :: InsOrdHashMap k v -> Bool Source #
size :: InsOrdHashMap k v -> Int Source #
:: (Eq k, Hashable k) | |
=> v | Default value to return. |
-> k | |
-> InsOrdHashMap k v | |
-> v |
insert :: (Eq k, Hashable k) => k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v Source #
insertWith :: (Eq k, Hashable k) => (v -> v -> v) -> k -> v -> InsOrdHashMap k v -> InsOrdHashMap k v Source #
delete :: (Eq k, Hashable k) => k -> InsOrdHashMap k v -> InsOrdHashMap k v Source #
adjust :: (Eq k, Hashable k) => (v -> v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v Source #
update :: (Eq k, Hashable k) => (a -> Maybe a) -> k -> InsOrdHashMap k a -> InsOrdHashMap k a Source #
alter :: (Eq k, Hashable k) => (Maybe v -> Maybe v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v Source #
Combine
union :: (Eq k, Hashable k) => InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v Source #
unionWith :: (Eq k, Hashable k) => (v -> v -> v) -> InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v Source #
The union of two maps. If a key occurs in both maps, the provided function (first argument) will be used to compute the result.
Ordered traversal will go thru keys in the first map first.
unionWithKey :: (Eq k, Hashable k) => (k -> v -> v -> v) -> InsOrdHashMap k v -> InsOrdHashMap k v -> InsOrdHashMap k v Source #
unions :: (Eq k, Hashable k, Foldable f) => f (InsOrdHashMap k v) -> InsOrdHashMap k v Source #
Transformations
map :: (v1 -> v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2 Source #
mapKeys :: (Eq k', Hashable k') => (k -> k') -> InsOrdHashMap k v -> InsOrdHashMap k' v Source #
Order preserving mapping of keys.
traverseKeys :: (Eq k', Hashable k', Applicative f) => (k -> f k') -> InsOrdHashMap k v -> f (InsOrdHashMap k' v) Source #
mapWithKey :: (k -> v1 -> v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2 Source #
traverseWithKey :: Applicative f => (k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b) Source #
Unordered
unorderedTraverse :: Applicative f => (a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b) Source #
More efficient than traverse
, when traversing in insertion order is not important.
unorderedTraverseWithKey :: Applicative f => (k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b) Source #
More efficient than traverseWithKey
, when traversing in insertion order is not important.
Difference and intersection
difference :: (Eq k, Hashable k) => InsOrdHashMap k v -> InsOrdHashMap k w -> InsOrdHashMap k v Source #
intersection :: (Eq k, Hashable k) => InsOrdHashMap k v -> InsOrdHashMap k w -> InsOrdHashMap k v Source #
intersectionWith :: (Eq k, Hashable k) => (v1 -> v2 -> v3) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3 Source #
intersectionWithKey :: (Eq k, Hashable k) => (k -> v1 -> v2 -> v3) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2 -> InsOrdHashMap k v3 Source #
Folds
foldl' :: (a -> v -> a) -> a -> InsOrdHashMap k v -> a Source #
foldlWithKey' :: (a -> k -> v -> a) -> a -> InsOrdHashMap k v -> a Source #
foldr :: (v -> a -> a) -> a -> InsOrdHashMap k v -> a Source #
foldrWithKey :: (k -> v -> a -> a) -> a -> InsOrdHashMap k v -> a Source #
foldMapWithKey :: Monoid m => (k -> a -> m) -> InsOrdHashMap k a -> m Source #
Unordered
unorderedFoldMap :: Monoid m => (a -> m) -> InsOrdHashMap k a -> m Source #
More efficient than foldMap
, when folding in insertion order is not important.
unorderedFoldMapWithKey :: Monoid m => (k -> a -> m) -> InsOrdHashMap k a -> m Source #
More efficient than foldMapWithKey
, when folding in insertion order is not important.
Filter
filter :: (v -> Bool) -> InsOrdHashMap k v -> InsOrdHashMap k v Source #
filterWithKey :: (k -> v -> Bool) -> InsOrdHashMap k v -> InsOrdHashMap k v Source #
mapMaybe :: (v1 -> Maybe v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2 Source #
mapMaybeWithKey :: (k -> v1 -> Maybe v2) -> InsOrdHashMap k v1 -> InsOrdHashMap k v2 Source #
Conversions
keys :: InsOrdHashMap k v -> [k] Source #
elems :: InsOrdHashMap k v -> [v] Source #
toList :: InsOrdHashMap k v -> [(k, v)] Source #
toRevList :: InsOrdHashMap k v -> [(k, v)] Source #
toHashMap :: InsOrdHashMap k v -> HashMap k v Source #
fromHashMap :: HashMap k v -> InsOrdHashMap k v Source #
Lenses
hashMap :: Iso (InsOrdHashMap k a) (InsOrdHashMap k b) (HashMap k a) (HashMap k b) Source #
This is a slight lie, as roundtrip doesn't preserve ordering.
unorderedTraversal :: Traversal (InsOrdHashMap k a) (InsOrdHashMap k b) a b Source #
Debugging
valid :: InsOrdHashMap k v -> Bool Source #
Test if the internal map structure is valid.