Safe Haskell | Safe-Inferred |
---|
Working with NE trees and forests.
- type NeTree a b = Tree (Either a b)
- type NeForest a b = Forest (Either a b)
- data Span w = Span {}
- leafSpan :: w -> Span w
- (<>) :: Ord w => Span w -> Span w -> Span w
- spanSet :: Ix w => Span w -> Set w
- span :: Tree (a, Span w) -> Span w
- spanTree :: Ord w => Tree (Either n w) -> Tree (Either n w, Span w)
- spanForest :: Ord w => Forest (Either n w) -> Forest (Either n w, Span w)
- unSpanTree :: Tree (k, Span w) -> Tree k
- unSpanForest :: Forest (k, Span w) -> Forest k
- sortTree :: Ord w => Tree (k, Span w) -> Tree (k, Span w)
- sortForest :: Ord w => Forest (k, Span w) -> Forest (k, Span w)
- mapForest :: (a -> b) -> Forest a -> Forest b
- mapTree :: (a -> b) -> Tree a -> Tree b
- onLeaf :: (a -> b) -> Either c a -> Either c b
- onNode :: (a -> b) -> Either a c -> Either b c
- onEither :: (a -> c) -> (b -> d) -> Either a b -> Either c d
- onBoth :: (a -> b) -> Either a a -> Either b b
- groupForestLeaves :: (b -> b -> Bool) -> NeForest a b -> NeForest a [b]
- groupTreeLeaves :: (b -> b -> Bool) -> NeTree a b -> NeTree a [b]
- module Data.Tree
Auxiliary types
type NeTree a b = Tree (Either a b)Source
A tree with a values in internal nodes and b values in leaves.
type NeForest a b = Forest (Either a b)Source
A forest with a values in internal nodes and b values in leaves.
Span
Spanning of a tree.
Trees with span
spanTree :: Ord w => Tree (Either n w) -> Tree (Either n w, Span w)Source
Annotate tree nodes with spanning info given the function which assignes indices to leaf nodes.
spanForest :: Ord w => Forest (Either n w) -> Forest (Either n w, Span w)Source
Annotate forest nodes with spanning info.
unSpanTree :: Tree (k, Span w) -> Tree kSource
Remove span annotations from the tree.
unSpanForest :: Forest (k, Span w) -> Forest kSource
Remove span annotations from the forest.
sortTree :: Ord w => Tree (k, Span w) -> Tree (k, Span w)Source
Sort the tree with respect to spanning info.
sortForest :: Ord w => Forest (k, Span w) -> Forest (k, Span w)Source
Sort the forest with respect to spanning info.
Utilities
onEither :: (a -> c) -> (b -> d) -> Either a b -> Either c dSource
Map the first function over internal node value and the second one over leaf value.
onBoth :: (a -> b) -> Either a a -> Either b bSource
Map one function over both node and leaf values.
groupForestLeaves :: (b -> b -> Bool) -> NeForest a b -> NeForest a [b]Source
Group leaves with respect to the given equality function.
groupTreeLeaves :: (b -> b -> Bool) -> NeTree a b -> NeTree a [b]Source
Group leaves with respect to the given equality function.
module Data.Tree