Safe Haskell | Safe |
---|---|
Language | Haskell98 |
- newtype TreeMap k x = TreeMap (Map k (Node k x))
- type Path = NonEmpty
- path :: k -> [k] -> Path k
- list :: Path k -> [k]
- reverse :: Path k -> Path k
- data Node k x = Node {
- node_size :: !Int
- node_value :: !(Maybe x)
- node_descendants :: !(TreeMap k x)
- node :: Maybe x -> TreeMap k x -> Node k x
- node_empty :: Node k x
- node_find :: Ord k => [k] -> Node k x -> Maybe (Node k x)
- empty :: TreeMap k x
- singleton :: Ord k => Path k -> x -> TreeMap k x
- leaf :: x -> Node k x
- insert :: Ord k => (x -> x -> x) -> Path k -> x -> TreeMap k x -> TreeMap k x
- from_List :: Ord k => (x -> x -> x) -> [(Path k, x)] -> TreeMap k x
- from_Map :: Ord k => (x -> x -> x) -> Map (Path k) x -> TreeMap k x
- nodes :: TreeMap k x -> Map k (Node k x)
- null :: TreeMap k x -> Bool
- size :: TreeMap k x -> Int
- find :: Ord k => Path k -> TreeMap k x -> Maybe x
- find_along :: Ord k => Path k -> TreeMap k x -> [x]
- find_node :: Ord k => Path k -> TreeMap k x -> Maybe (Node k x)
- union :: Ord k => (x -> x -> x) -> TreeMap k x -> TreeMap k x -> TreeMap k x
- unions :: Ord k => (x -> x -> x) -> [TreeMap k x] -> TreeMap k x
- map :: Ord k => (x -> y) -> TreeMap k x -> TreeMap k y
- map_monotonic :: (Ord k, Ord l) => (k -> l) -> (x -> y) -> TreeMap k x -> TreeMap l y
- map_by_depth_first :: Ord k => (TreeMap k y -> Maybe x -> y) -> TreeMap k x -> TreeMap k y
- alterl_path :: Ord k => (Maybe x -> Maybe x) -> Path k -> TreeMap k x -> TreeMap k x
- foldl_with_Path :: Ord k => (a -> Path k -> x -> a) -> a -> TreeMap k x -> a
- foldl_with_Path_and_Node :: Ord k => (a -> Node k x -> Path k -> x -> a) -> a -> TreeMap k x -> a
- foldr_with_Path :: Ord k => (Path k -> x -> a -> a) -> a -> TreeMap k x -> a
- foldr_with_Path_and_Node :: Ord k => (Node k x -> Path k -> x -> a -> a) -> a -> TreeMap k x -> a
- foldl_path :: Ord k => (Path k -> x -> a -> a) -> Path k -> TreeMap k x -> a -> a
- foldr_path :: Ord k => (Path k -> x -> a -> a) -> Path k -> TreeMap k x -> a -> a
- flatten :: Ord k => (x -> y) -> TreeMap k x -> Map (Path k) y
- flatten_with_Path :: Ord k => (Path k -> x -> y) -> TreeMap k x -> Map (Path k) y
- filter :: Ord k => (x -> Bool) -> TreeMap k x -> TreeMap k x
- filter_with_Path :: Ord k => (Path k -> x -> Bool) -> TreeMap k x -> TreeMap k x
- filter_with_Path_and_Node :: Ord k => (Node k x -> Path k -> x -> Bool) -> TreeMap k x -> TreeMap k x
- map_Maybe :: Ord k => (x -> Maybe y) -> TreeMap k x -> TreeMap k y
- map_Maybe_with_Path :: Ord k => (Path k -> x -> Maybe y) -> TreeMap k x -> TreeMap k y
- map_Maybe_with_Path_and_Node :: Ord k => (Node k x -> Path k -> x -> Maybe y) -> TreeMap k x -> TreeMap k y
Documentation
Type TreeMap
Ord k => Functor (TreeMap k) Source # | |
Ord k => Foldable (TreeMap k) Source # | |
Ord k => Traversable (TreeMap k) Source # | |
(Eq x, Eq k) => Eq (TreeMap k x) Source # | |
(Ord k, Data x, Data k) => Data (TreeMap k x) Source # | |
(Show x, Show k) => Show (TreeMap k x) Source # | |
(Ord k, Monoid v) => Monoid (TreeMap k v) Source # | |
(Ord k, NFData k, NFData x) => NFData (TreeMap k x) Source # | |
Type Path
Type Node
Node | |
|
Ord k => Functor (Node k) Source # | |
Ord k => Foldable (Node k) Source # | |
Ord k => Traversable (Node k) Source # | |
(Eq k, Eq x) => Eq (Node k x) Source # | |
(Ord k, Data x, Data k) => Data (Node k x) Source # | |
(Show k, Show x) => Show (Node k x) Source # | |
(Ord k, Monoid v) => Monoid (Node k v) Source # | |
(Ord k, NFData k, NFData x) => NFData (Node k x) Source # | |
node_empty :: Node k x Source #
Construct
Size
size :: TreeMap k x -> Int Source #
Return the number of non-Nothing
node_value
s in the given TreeMap
.
- Complexity: O(r) where r is the size of the root
Map
.
Find
find :: Ord k => Path k -> TreeMap k x -> Maybe x Source #
Return the value (if any) associated with the given Path
.
find_along :: Ord k => Path k -> TreeMap k x -> [x] Source #
Return the values (if any) associated with the prefixes of the given Path
(included).
Union
Map
map :: Ord k => (x -> y) -> TreeMap k x -> TreeMap k y Source #
Return the given TreeMap
with each non-Nothing
node_value
mapped by the given function.
map_monotonic :: (Ord k, Ord l) => (k -> l) -> (x -> y) -> TreeMap k x -> TreeMap l y Source #
Return the given TreeMap
with each Path
section
and each non-Nothing
node_value
mapped by the given functions.
WARNING: the function mapping Path
sections must be monotonic,
like in mapKeysMonotonic
.
map_by_depth_first :: Ord k => (TreeMap k y -> Maybe x -> y) -> TreeMap k x -> TreeMap k y Source #
Return the given TreeMap
with each node_value
mapped by the given function supplied with
the already mapped node_descendants
of the current Node
.
Alter
Fold
foldl_with_Path :: Ord k => (a -> Path k -> x -> a) -> a -> TreeMap k x -> a Source #
Return the given accumulator folded by the given function
applied on non-Nothing
node_value
s
from left to right through the given TreeMap
.
foldl_with_Path_and_Node :: Ord k => (a -> Node k x -> Path k -> x -> a) -> a -> TreeMap k x -> a Source #
Return the given accumulator folded by the given function
applied on non-Nothing
Node
s and node_value
s
from left to right through the given TreeMap
.
foldr_with_Path :: Ord k => (Path k -> x -> a -> a) -> a -> TreeMap k x -> a Source #
Return the given accumulator folded by the given function
applied on non-Nothing
node_value
s
from right to left through the given TreeMap
.
foldr_with_Path_and_Node :: Ord k => (Node k x -> Path k -> x -> a -> a) -> a -> TreeMap k x -> a Source #
Return the given accumulator folded by the given function
applied on non-Nothing
Node
s and node_value
s
from right to left through the given TreeMap
.
foldl_path :: Ord k => (Path k -> x -> a -> a) -> Path k -> TreeMap k x -> a -> a Source #
Return the given accumulator folded by the given function
applied on non-Nothing
node_value
s
from left to right along the given Path
.
foldr_path :: Ord k => (Path k -> x -> a -> a) -> Path k -> TreeMap k x -> a -> a Source #
Return the given accumulator folded by the given function
applied on non-Nothing
node_value
s
from right to left along the given Path
.
Flatten
flatten :: Ord k => (x -> y) -> TreeMap k x -> Map (Path k) y Source #
Return a Map
associating each Path
leading to a non-Nothing
node_value
in the given TreeMap
,
with its value mapped by the given function.
Filter
filter :: Ord k => (x -> Bool) -> TreeMap k x -> TreeMap k x Source #
Return the given TreeMap
keeping only its non-Nothing
node_value
s
passing the given predicate.
filter_with_Path_and_Node :: Ord k => (Node k x -> Path k -> x -> Bool) -> TreeMap k x -> TreeMap k x Source #
Like filter_with_Path
but with also the current Node
given to the predicate.
map_Maybe :: Ord k => (x -> Maybe y) -> TreeMap k x -> TreeMap k y Source #
Return the given TreeMap
mapping its non-Nothing
node_value
s
and keeping only the non-Nothing
results.
map_Maybe_with_Path_and_Node :: Ord k => (Node k x -> Path k -> x -> Maybe y) -> TreeMap k x -> TreeMap k y Source #
Like map_Maybe_with_Path
but with also the current Node
given to the predicate.