hledger-lib-1.12: 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 Source #

subs :: Tree a -> Forest a Source #

branches :: Tree a -> Forest a Source #

leaves :: Tree a -> [a] Source #

List just the leaf nodes of a tree

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

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) Source #

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 Source #

remove all nodes past a certain depth

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

apply f to all tree nodes

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

remove all subtrees whose nodes do not fulfill predicate

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

is predicate true in any node of tree ?

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

show a compact ascii representation of a tree

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

show a compact ascii representation of a forest

newtype FastTree a Source #

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) Source # |
Instance details Defined in Hledger.Utils.Tree Methods (==) :: FastTree a -> FastTree a -> Bool Source # (/=) :: FastTree a -> FastTree a -> Bool Source #
Ord a => Ord (FastTree a) Source # |

Instance details

Defined in Hledger.Utils.Tree

Methods

compare :: FastTree a -> FastTree a -> Ordering Source #

(<) :: FastTree a -> FastTree a -> Bool Source #

(<=) :: FastTree a -> FastTree a -> Bool Source #

(>) :: FastTree a -> FastTree a -> Bool Source #

(>=) :: FastTree a -> FastTree a -> Bool Source #

max :: FastTree a -> FastTree a -> FastTree a Source #

min :: FastTree a -> FastTree a -> FastTree a Source #

Show a => Show (FastTree a) Source # |
Instance details Defined in Hledger.Utils.Tree Methods showsPrec :: Int -> FastTree a -> ShowS Source # show :: FastTree a -> String Source # showList :: [FastTree a] -> ShowS Source #

emptyTree :: FastTree a Source #

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

treeFromPath :: [a] -> FastTree a Source #

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