Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype TreeMap k x = TreeMap (Map k (Node k x))
- type Path k = NonNull [k]
- path :: k -> [k] -> Path k
- (<|) :: k -> [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
- nodeEmpty :: Node k x
- nodeLookup :: 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
- fromList :: Ord k => (x -> x -> x) -> [(Path k, x)] -> TreeMap k x
- fromMap :: Ord k => 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
- lookup :: Ord k => Path k -> TreeMap k x -> Maybe x
- lookupAlong :: Ord k => Path k -> TreeMap k x -> [x]
- lookupNode :: 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
- mapMonotonic :: (Ord k, Ord l) => (k -> l) -> (x -> y) -> TreeMap k x -> TreeMap l y
- mapByDepthFirst :: 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
- foldlWithPath :: Ord k => (a -> Path k -> x -> a) -> a -> TreeMap k x -> a
- foldlWithPathAndNode :: Ord k => (a -> Node k x -> Path k -> x -> a) -> a -> TreeMap k x -> a
- foldrWithPath :: Ord k => (Path k -> x -> a -> a) -> a -> TreeMap k x -> a
- foldrWithPathAndNode :: Ord k => (Node k x -> Path k -> x -> a -> a) -> a -> TreeMap k x -> a
- foldlPath :: Ord k => (Path k -> x -> a -> a) -> Path k -> TreeMap k x -> a -> a
- foldrPath :: 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
- flattenWithPath :: Ord k => (Path k -> x -> y) -> TreeMap k x -> Map (Path k) y
- filter :: Ord k => (x -> Bool) -> TreeMap k x -> TreeMap k x
- filterWithPath :: Ord k => (Path k -> x -> Bool) -> TreeMap k x -> TreeMap k x
- filterWithPathAndNode :: Ord k => (Node k x -> Path k -> x -> Bool) -> TreeMap k x -> TreeMap k x
- mapMaybe :: Ord k => (x -> Maybe y) -> TreeMap k x -> TreeMap k y
- mapMaybeWithPath :: Ord k => (Path k -> x -> Maybe y) -> TreeMap k x -> TreeMap k y
- mapMaybeWithPathAndNode :: Ord k => (Node k x -> Path k -> x -> Maybe y) -> TreeMap k x -> TreeMap k y
- (\\) :: Ord k => TreeMap k x -> TreeMap k y -> TreeMap k x
- intersection :: Ord k => (Maybe x -> Maybe y -> Maybe z) -> TreeMap k x -> TreeMap k y -> TreeMap k z
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 # | |
(Ord x, Ord k) => Ord (TreeMap k x) Source # | |
(Show x, Show k) => Show (TreeMap k x) Source # | |
(Ord k, Semigroup v) => Semigroup (TreeMap k v) 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 # | |
(Ord k, Ord x) => Ord (Node k x) Source # | |
(Show k, Show x) => Show (Node k x) Source # | |
(Ord k, Semigroup v) => Semigroup (Node k v) Source # | |
(Ord k, Semigroup v) => Monoid (Node k v) Source # | |
(Ord k, NFData k, NFData x) => NFData (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
lookup :: Ord k => Path k -> TreeMap k x -> Maybe x Source #
Return the value (if any) associated with the given Path
.
lookupAlong :: 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.
mapMonotonic :: (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
.
mapByDepthFirst :: 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
foldlWithPath :: 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
.
foldlWithPathAndNode :: 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
.
foldrWithPath :: 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
.
foldrWithPathAndNode :: 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
.
foldlPath :: 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
.
foldrPath :: 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.
filterWithPathAndNode :: Ord k => (Node k x -> Path k -> x -> Bool) -> TreeMap k x -> TreeMap k x Source #
Like filterWithPath
but with also the current Node
given to the predicate.
mapMaybe :: 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.
mapMaybeWithPathAndNode :: Ord k => (Node k x -> Path k -> x -> Maybe y) -> TreeMap k x -> TreeMap k y Source #
Like mapMaybeWithPath
but with also the current Node
given to the predicate.
Intersection
intersection :: Ord k => (Maybe x -> Maybe y -> Maybe z) -> TreeMap k x -> TreeMap k y -> TreeMap k z Source #