Safe Haskell | None |
---|

Extra utils for Data.Map.

## Synopsis

- get :: Ord k => a -> k -> Map k a -> a
- soft_insert :: Ord k => k -> v -> Map k v -> Map k v
- filter_key :: (k -> Bool) -> Map k a -> Map k a
- delete_keys :: Ord k => [k] -> Map k a -> Map k a
- insert_list :: Ord k => [(k, v)] -> Map k v -> Map k v
- split2 :: Ord k => k -> Map k a -> (Map k a, Map k a)
- split3 :: Ord k => k -> k -> Map k a -> (Map k a, Map k a, Map k a)
- within :: Ord k => k -> k -> Map k a -> Map k a
- lookup_below :: Ord k => k -> Map k a -> Maybe.Maybe (k, a)
- invert :: Ord a => Map k a -> Map a k
- multimap :: Ord k => [(k, a)] -> Map k [a]
- unique :: Ord a => [(a, b)] -> (Map a b, [(a, b)])
- unique2 :: Ord k => [(k, v)] -> (Map k v, [(k, [v])])
- zip_intersection :: Ord k => Map k v1 -> Map k v2 -> [(k, v1, v2)]
- pairs :: Ord k => Map k v1 -> Map k v2 -> [(k, Seq.Paired v1 v2)]
- unique_union :: Ord k => Map k a -> Map k a -> (Map k a, Map k a)
- unique_unions :: Ord k => [Map k a] -> (Map k a, Map k a)
- min :: Map k a -> Maybe.Maybe (k, a)
- max :: Map k a -> Maybe.Maybe (k, a)
- mappend :: (Ord k, Monoid a) => Map k a -> Map k a -> Map k a
- mconcat :: (Ord k, Monoid a) => [Map k a] -> Map k a

# Documentation

soft_insert :: Ord k => k -> v -> Map k v -> Map k v Source #

This is like `insert`

, but do nothing if the key is already present.

split2 :: Ord k => k -> Map k a -> (Map k a, Map k a) Source #

Like `split`

, except include a matched key in the above map.

split3 :: Ord k => k -> k -> Map k a -> (Map k a, Map k a, Map k a) Source #

Split the map into the maps below, within, and above the given range.
`low`

to `high`

is half-open, as usual.

within :: Ord k => k -> k -> Map k a -> Map k a Source #

Return the subset of the map that is between a half-open low and high key.

lookup_below :: Ord k => k -> Map k a -> Maybe.Maybe (k, a) Source #

multimap :: Ord k => [(k, a)] -> Map k [a] Source #

TODO Would it be more efficient to do 'fromListWith (++)'?

unique :: Ord a => [(a, b)] -> (Map a b, [(a, b)]) Source #

Like Map.fromList, but only accept the first of duplicate keys, and also return the rejected duplicates.

unique2 :: Ord k => [(k, v)] -> (Map k v, [(k, [v])]) Source #

Make a map, but if any keys collide, omit that key and return it along with the multiple values.

zip_intersection :: Ord k => Map k v1 -> Map k v2 -> [(k, v1, v2)] Source #

Given two maps, pair up the elements in `map1`

with a samed-keyed element
in `map2`

, if there is one. Elements that are only in `map1`

or `map2`

will
not be included in the output.

pairs :: Ord k => Map k v1 -> Map k v2 -> [(k, Seq.Paired v1 v2)] Source #

Pair up elements from each map with equal keys.

Like `union`

, but also return a map of rejected duplicate keys from
the map on the right.

unique_unions :: Ord k => [Map k a] -> (Map k a, Map k a) Source #

Like `unions`

, but return a map of the rejected keys. Like
Map.unions, the first key in the list wins. If there are multiple
conflicting keys, only the first one will show up in the reject map.

min :: Map k a -> Maybe.Maybe (k, a) Source #

Safe versions of findMin and findMax.

max :: Map k a -> Maybe.Maybe (k, a) Source #