hledger-lib-1.3: Core data types, parsers and functionality for the hledger accounting tools

Safe Haskell | None
Language | Haskell2010

Hledger.Utils.Tree

Synopsis

- root :: Tree a -> a
- subs :: Tree a -> Forest a
- branches :: Tree a -> Forest a
- leaves :: Tree a -> [a]
- subtreeat :: Eq a => a -> Tree a -> Maybe (Tree a)
- subtreeinforest :: Eq a => a -> [Tree a] -> Maybe (Tree a)
- treeprune :: Int -> Tree a -> Tree a
- treemap :: (a -> b) -> Tree a -> Tree b
- treefilter :: (a -> Bool) -> Tree a -> Tree a
- treeany :: (a -> Bool) -> Tree a -> Bool
- showtree :: Show a => Tree a -> String
- showforest :: Show a => Forest a -> String
- newtype FastTree a = T (Map a (FastTree a))
- emptyTree :: FastTree a
- mergeTrees :: Ord a => FastTree a -> FastTree a -> FastTree a
- treeFromPath :: [a] -> FastTree a
- treeFromPaths :: Ord a => [[a]] -> FastTree a

# Documentation

root :: Tree a -> a #

subs :: Tree a -> Forest a #

branches :: Tree a -> Forest a #

leaves :: Tree a -> [a] #

List just the leaf nodes of a tree

subtreeat :: Eq a => a -> Tree a -> Maybe (Tree a) #

get the sub-tree rooted at the first (left-most, depth-first) occurrence of the specified node value

subtreeinforest :: Eq a => a -> [Tree a] -> Maybe (Tree a) #

get the sub-tree for the specified node value in the first tree in forest in which it occurs.

treeprune :: Int -> Tree a -> Tree a #

remove all nodes past a certain depth

treemap :: (a -> b) -> Tree a -> Tree b #

apply f to all tree nodes

treefilter :: (a -> Bool) -> Tree a -> Tree a #

remove all subtrees whose nodes do not fulfill predicate

treeany :: (a -> Bool) -> Tree a -> Bool #

is predicate true in any node of tree ?

showtree :: Show a => Tree a -> String #

show a compact ascii representation of a tree

showforest :: Show a => Forest a -> String #

show a compact ascii representation of a forest

newtype FastTree a #

An efficient-to-build tree suggested by Cale Gibbard, probably better than accountNameTreeFrom.

Constructors

T (Map a (FastTree a)) |

Instances

Eq a => Eq (FastTree a) # |
Methods (==) :: FastTree a -> FastTree a -> Bool # (/=) :: FastTree a -> FastTree a -> Bool #
Ord a => Ord (FastTree a) # |
Methods compare :: FastTree a -> FastTree a -> Ordering # (<) :: FastTree a -> FastTree a -> Bool # (<=) :: FastTree a -> FastTree a -> Bool # (>) :: FastTree a -> FastTree a -> Bool # (>=) :: FastTree a -> FastTree a -> Bool # max :: FastTree a -> FastTree a -> FastTree a # min :: FastTree a -> FastTree a -> FastTree a #
Show a => Show (FastTree a) # |
Methods showsPrec :: Int -> FastTree a -> ShowS # show :: FastTree a -> String # showList :: [FastTree a] -> ShowS #

emptyTree :: FastTree a #

mergeTrees :: Ord a => FastTree a -> FastTree a -> FastTree a #

treeFromPath :: [a] -> FastTree a #

treeFromPaths :: Ord a => [[a]] -> FastTree a #