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
- data MKMap k v
- at :: Ord k => MKMap k v -> k -> v
- (!) :: 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
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.