Maintainer | Profpatsch |
---|---|
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
Still very much experimental and missing lots of functions and testing.
Internally, a MKMap
is two maps, a keyMap
referencing an intermediate key
(whose type can be chosen freely and which is incremented sequentially), and
a valueMap
going from intermediate key to final value.
A correct implementation guarantees that
- the internal structure can’t be corrupted by operations declared safe
- adding and removing keys does not make values inaccessible (thus leaking memory) and doesn’t insert unnecessary values
Synopsis
- data MKMap k v
- at :: (HasCallStack, Ord k) => MKMap k v -> k -> v
- (!) :: (HasCallStack, Ord k) => MKMap k v -> k -> v
- mkMKMap :: forall k ik v. (Ord k, Ord ik, Enum ik, Bounded ik) => Proxy ik -> MKMap k v
- fromList :: forall ik k v. (Ord k, Ord ik, Enum ik, Bounded ik) => Proxy ik -> [(NonEmpty k, v)] -> MKMap k v
- toList :: MKMap k v -> [(NonEmpty k, v)]
- insert :: Ord k => k -> v -> MKMap k v -> MKMap k v
- flattenKeys :: Ord k => MKMap k v -> Map k v
- keys :: Ord k => MKMap k v -> [k]
- values :: MKMap k v -> [v]
Documentation
A Map
-like structure where multiple keys can point
to the same value, with corresponding abstracted interface.
Internally, we use two maps connected by an intermediate key.
The intermediate key (ik
) can be anything implementing
Ord
(for Map
), Bounded
(to get the first value)
and Enum
(for succ
).
Instances
Functor (MKMap k) Source # | |
Foldable (MKMap k) Source # | |
Defined in Data.MultiKeyedMap fold :: Monoid m => MKMap k m -> m # foldMap :: Monoid m => (a -> m) -> MKMap k a -> m # foldr :: (a -> b -> b) -> b -> MKMap k a -> b # foldr' :: (a -> b -> b) -> b -> MKMap k a -> b # foldl :: (b -> a -> b) -> b -> MKMap k a -> b # foldl' :: (b -> a -> b) -> b -> MKMap k a -> b # foldr1 :: (a -> a -> a) -> MKMap k a -> a # foldl1 :: (a -> a -> a) -> MKMap k a -> a # elem :: Eq a => a -> MKMap k a -> Bool # maximum :: Ord a => MKMap k a -> a # minimum :: Ord a => MKMap k a -> a # | |
Traversable (MKMap k) Source # | |
(Eq k, Ord k, Eq v) => Eq (MKMap k v) Source # | |
(Show k, Show v) => Show (MKMap k v) Source # | |
Create a MKMap
given a type for the internally used intermediate key.
:: (Ord k, Ord ik, Enum ik, Bounded ik) | |
=> Proxy ik | type of intermediate key |
-> [(NonEmpty k, v)] | list of |
-> MKMap k v | new map |
Build a map from a list of key/value pairs.
insert :: Ord k => k -> v -> MKMap k v -> MKMap k v Source #
Equivalent to insert
, if the key doesn’t exist a new
singleton key is added.