Safe Haskell | None |
---|---|
Language | Haskell2010 |
HashMap to multiple values.
Synopsis
- newtype MultiMap k v = MultiMap {
- unMultiMap :: HashMap k (Set v)
- singleton :: Hashable k => k -> v -> MultiMap k v
- fromMap :: HashMap k (Set v) -> MultiMap k v
- toMap :: MultiMap k v -> HashMap k (Set v)
- fromList :: (Eq k, Hashable k, Ord v) => [(k, v)] -> MultiMap k v
- toList :: MultiMap k v -> [(k, [v])]
- lookup :: (Eq k, Hashable k) => k -> MultiMap k v -> Set v
- insert :: (Eq k, Hashable k, Ord v) => k -> v -> MultiMap k v -> MultiMap k v
- keys :: MultiMap k v -> [k]
- elems :: MultiMap k v -> [Set v]
Documentation
Map from keys to sets of values
MultiMap | |
|
Instances
(Eq k, Eq v) => Eq (MultiMap k v) Source # | |
(Show k, Show v) => Show (MultiMap k v) Source # | |
(Eq k, Hashable k, Ord v) => Semigroup (MultiMap k v) Source # | |
(Eq k, Hashable k, Ord v) => Monoid (MultiMap k v) Source # | |
(ToJSON v, ToJSONKey k) => ToJSON (MultiMap k v) Source # | |
Defined in Data.HashMap.Strict.Multi toJSON :: MultiMap k v -> Value toEncoding :: MultiMap k v -> Encoding toJSONList :: [MultiMap k v] -> Value toEncodingList :: [MultiMap k v] -> Encoding |
singleton :: Hashable k => k -> v -> MultiMap k v Source #
Construct a MmultiMap
with a single key, to which only one
value is associated.
fromMap :: HashMap k (Set v) -> MultiMap k v Source #
Construct a MultiMap
with the supplied mappings.
toList :: MultiMap k v -> [(k, [v])] Source #
Creates an association list from a MultiMap
.
Each set of values associated with a given key is transformed back into a list.
lookup :: (Eq k, Hashable k) => k -> MultiMap k v -> Set v Source #
Return the value to which the specified key is mapped, or Nothing
if
this map contains no mapping for the key.