- data TreeLoc a = Loc {}
- fromTree :: Tree a -> TreeLoc a
- fromForest :: Forest a -> Maybe (TreeLoc a)
- toForest :: TreeLoc a -> Forest a
- toTree :: TreeLoc a -> Tree a
- parent :: TreeLoc a -> Maybe (TreeLoc a)
- root :: TreeLoc a -> TreeLoc a
- getChild :: Int -> TreeLoc a -> Maybe (TreeLoc a)
- findChild :: (Tree a -> Bool) -> TreeLoc a -> Maybe (TreeLoc a)
- firstChild :: TreeLoc a -> Maybe (TreeLoc a)
- lastChild :: TreeLoc a -> Maybe (TreeLoc a)
- left :: TreeLoc a -> Maybe (TreeLoc a)
- right :: TreeLoc a -> Maybe (TreeLoc a)
- isRoot :: TreeLoc a -> Bool
- isFirst :: TreeLoc a -> Bool
- isLast :: TreeLoc a -> Bool
- isLeaf :: TreeLoc a -> Bool
- isChild :: TreeLoc a -> Bool
- hasChildren :: TreeLoc a -> Bool
- insertLeft :: Tree a -> TreeLoc a -> TreeLoc a
- insertRight :: Tree a -> TreeLoc a -> TreeLoc a
- 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)
- setTree :: Tree a -> TreeLoc a -> TreeLoc a
- modifyTree :: (Tree a -> Tree a) -> TreeLoc a -> TreeLoc a
- modifyLabel :: (a -> a) -> TreeLoc a -> TreeLoc a
- setLabel :: a -> TreeLoc a -> TreeLoc a
- getLabel :: TreeLoc a -> a
Documentation
Conversions
fromForest :: Forest a -> Maybe (TreeLoc a)Source
The location of the first tree in a forest.
Moving around
getChild :: Int -> TreeLoc a -> Maybe (TreeLoc a)Source
The child with the given index (starting from 0).
findChild :: (Tree a -> Bool) -> TreeLoc a -> Maybe (TreeLoc a)Source
The first child that satisfies a predicate.
firstChild :: TreeLoc a -> Maybe (TreeLoc a)Source
The first child of the given location.
Node classification
hasChildren :: TreeLoc a -> BoolSource
Do we have children?
Tree-specific mutation
insertLeft :: Tree a -> TreeLoc a -> TreeLoc aSource
Insert a tree to the left of the current position. The new tree becomes the current tree.
insertRight :: Tree a -> TreeLoc a -> TreeLoc aSource
Insert a tree to the right of the current position. The new tree becomes the current tree.
insertDownFirst :: Tree a -> TreeLoc a -> TreeLoc aSource
insertDownLast :: Tree a -> TreeLoc a -> TreeLoc aSource
delete :: TreeLoc a -> Maybe (TreeLoc a)Source
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
modifyLabel :: (a -> a) -> TreeLoc a -> TreeLoc aSource
Modify the label at the current node.