Grab bag of utility functions.
- tieredForest :: Ord k => (a -> [k]) -> [a] -> Forest (k, [a])
- tieredPostings :: [(a, Posting)] -> Forest (SubAccount, [(a, Posting)])
- filterForest :: (a -> Bool) -> Forest a -> Forest a
- balances :: ShowZeroBalances -> [(a, Posting)] -> Forest (SubAccount, Balance)
- flatten :: Forest (SubAccount, Balance) -> [(Account, Balance)]
- treeWithParents :: Tree a -> Tree (a, [a])
- forestWithParents :: Forest a -> Forest (a, [a])
- sumForest :: s -> (s -> s -> s) -> Forest (a, s) -> (Forest (a, s), s)
- sumTree :: s -> (s -> s -> s) -> Tree (a, s) -> Tree (a, s)
- boxesBalance :: [(a, Posting)] -> Balance
- labelLevels :: Tree a -> Tree (Int, a)
- sortForest :: (a -> a -> Ordering) -> Forest a -> Forest a
- sortTree :: (a -> a -> Ordering) -> Tree a -> Tree a
- lastMode :: Ord a => [a] -> Maybe a
|:: Ord k|
|=> (a -> [k])|
Extracts a key from the elements we are putting in the tree. If this function returns an empty list for any element, the element will not appear in the tiered forest.
|-> Forest (k, [a])|
Constructs a forest sorted into tiers based on lists of keys that are extracted from the elements.
Takes a list of postings and puts them into a Forest. Each level of each of the trees corresponds to a sub account. The label of the node tells you the sub account name and gives you a list of the postings at that level.
Keeps only Trees that match a given condition. First examines child trees to determine whether they should be retained. If a child tree is retained, does not delete the parent tree.
Puts all Boxes into a Tree and sums the balances. Removes accounts that have empty balances if requested. Does NOT sum balances from the bottom up.
Takes a tree of Balances (like what is produced by the
function) and produces a flat list of accounts with the balance of
Takes a Tree and returns a Tree where each node has information about its parent Nodes. The list of parent nodes has the most immediate parent first and the most distant parent last.
Takes a Forest and returns a Forest where each node has information about its parent Nodes.
Sums a forest from the bottom up. Returns a pair, where the first element is the forest, but with the second element of each node replaced with the sum of that node and all its children. The second element is the sum of all the second elements in the forest.
Sums a tree from the bottom up.
Label each level of a Tree with an integer indicating how deep it is. The top node of the tree is level 0.