| |||||||||||||||||
| |||||||||||||||||
| |||||||||||||||||
Synopsis | |||||||||||||||||
Documentation | |||||||||||||||||
data TreeLoc a | |||||||||||||||||
| |||||||||||||||||
Conversions | |||||||||||||||||
fromTree :: Tree a -> TreeLoc a | |||||||||||||||||
A location corresponding to the root of the given tree. | |||||||||||||||||
fromForest :: Forest a -> Maybe (TreeLoc a) | |||||||||||||||||
The location of the first tree in a forest. | |||||||||||||||||
toForest :: TreeLoc a -> Forest a | |||||||||||||||||
Computes the forest containing this location. | |||||||||||||||||
toTree :: TreeLoc a -> Tree a | |||||||||||||||||
Computes the tree containing this location. | |||||||||||||||||
Moving around | |||||||||||||||||
parent :: TreeLoc a -> Maybe (TreeLoc a) | |||||||||||||||||
The parent of the given location. | |||||||||||||||||
root :: TreeLoc a -> TreeLoc a | |||||||||||||||||
The top-most parent of the given location. | |||||||||||||||||
getChild :: Int -> TreeLoc a -> Maybe (TreeLoc a) | |||||||||||||||||
The child with the given index (starting from 0). | |||||||||||||||||
findChild :: (Tree a -> Bool) -> TreeLoc a -> Maybe (TreeLoc a) | |||||||||||||||||
The first child that satisfies a predicate. | |||||||||||||||||
firstChild :: TreeLoc a -> Maybe (TreeLoc a) | |||||||||||||||||
The first child of the given location. | |||||||||||||||||
lastChild :: TreeLoc a -> Maybe (TreeLoc a) | |||||||||||||||||
The last child of the given location. | |||||||||||||||||
left :: TreeLoc a -> Maybe (TreeLoc a) | |||||||||||||||||
The left sibling of the given location. | |||||||||||||||||
right :: TreeLoc a -> Maybe (TreeLoc a) | |||||||||||||||||
The right sibling of the given location. | |||||||||||||||||
Node classification | |||||||||||||||||
isRoot :: TreeLoc a -> Bool | |||||||||||||||||
Are we at the top of the tree? | |||||||||||||||||
isFirst :: TreeLoc a -> Bool | |||||||||||||||||
Are we at the left end of the the tree? | |||||||||||||||||
isLast :: TreeLoc a -> Bool | |||||||||||||||||
Are we at the right end of the tree? | |||||||||||||||||
isLeaf :: TreeLoc a -> Bool | |||||||||||||||||
Are we at the bottom of the tree? | |||||||||||||||||
isChild :: TreeLoc a -> Bool | |||||||||||||||||
Do we have a parent? | |||||||||||||||||
hasChildren :: TreeLoc a -> Bool | |||||||||||||||||
Do we have children? | |||||||||||||||||
Tree-specific mutation | |||||||||||||||||
insertLeft :: Tree a -> TreeLoc a -> TreeLoc a | |||||||||||||||||
Insert a tree to the left of the current position. The new tree becomes the current tree. | |||||||||||||||||
insertRight :: Tree a -> TreeLoc a -> TreeLoc a | |||||||||||||||||
Insert a tree to the right of the current position. The new tree becomes the current tree. | |||||||||||||||||
insertDownFirst :: Tree a -> TreeLoc a -> TreeLoc a | |||||||||||||||||
insertDownLast :: Tree a -> TreeLoc a -> TreeLoc a | |||||||||||||||||
insertDownAt :: Int -> Tree a -> TreeLoc a -> Maybe (TreeLoc a) | |||||||||||||||||
delete :: TreeLoc a -> Maybe (TreeLoc a) | |||||||||||||||||
Delete the current node. The new position is: * the right sibling, or if none * the left sibling, or if none * the parent. | |||||||||||||||||
Working with the current tree | |||||||||||||||||
setTree :: Tree a -> TreeLoc a -> TreeLoc a | |||||||||||||||||
Change the current tree. | |||||||||||||||||
modifyTree :: (Tree a -> Tree a) -> TreeLoc a -> TreeLoc a | |||||||||||||||||
Modify the current tree. | |||||||||||||||||
modifyLabel :: (a -> a) -> TreeLoc a -> TreeLoc a | |||||||||||||||||
Modify the label at the current node. | |||||||||||||||||
setLabel :: a -> TreeLoc a -> TreeLoc a | |||||||||||||||||
Change the label at the current node. | |||||||||||||||||
getLabel :: TreeLoc a -> a | |||||||||||||||||
Produced by Haddock version 2.3.0 |