rosezipper-0.1: Generic zipper implementation for Data.TreeSource codeContentsIndex
Data.Tree.Zipper
Contents
Conversions
Moving around
Node classification
Tree-specific mutation
Working with the current tree
Synopsis
data TreeLoc a = Loc {
tree :: Tree a
lefts :: Forest a
rights :: Forest a
parents :: [(Forest a, a, Forest a)]
}
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
data TreeLoc a Source
A position within a Tree.
Constructors
Loc
tree :: Tree aThe currently selected tree.
lefts :: Forest aSiblings on the left, closest first.
rights :: Forest aSiblings on the right, closest first.
parents :: [(Forest a, a, Forest a)]The contexts of the parents for this location.
show/hide Instances
Eq a => Eq (TreeLoc a)
Read a => Read (TreeLoc a)
Show a => Show (TreeLoc a)
Conversions
fromTree :: Tree a -> TreeLoc aSource
A location corresponding to the root of the given tree.
fromForest :: Forest a -> Maybe (TreeLoc a)Source
The location of the first tree in a forest.
toForest :: TreeLoc a -> Forest aSource
Computes the forest containing this location.
toTree :: TreeLoc a -> Tree aSource
Computes the tree containing this location.
Moving around
parent :: TreeLoc a -> Maybe (TreeLoc a)Source
The parent of the given location.
root :: TreeLoc a -> TreeLoc aSource
The top-most parent of the given location.
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.
lastChild :: TreeLoc a -> Maybe (TreeLoc a)Source
The last child of the given location.
left :: TreeLoc a -> Maybe (TreeLoc a)Source
The left sibling of the given location.
right :: TreeLoc a -> Maybe (TreeLoc a)Source
The right sibling of the given location.
Node classification
isRoot :: TreeLoc a -> BoolSource
Are we at the top of the tree?
isFirst :: TreeLoc a -> BoolSource
Are we at the left end of the the tree?
isLast :: TreeLoc a -> BoolSource
Are we at the right end of the tree?
isLeaf :: TreeLoc a -> BoolSource
Are we at the bottom of the tree?
isChild :: TreeLoc a -> BoolSource
Do we have a parent?
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
insertDownAt :: Int -> Tree a -> TreeLoc a -> Maybe (TreeLoc a)Source
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
setTree :: Tree a -> TreeLoc a -> TreeLoc aSource
Change the current tree.
modifyTree :: (Tree a -> Tree a) -> TreeLoc a -> TreeLoc aSource
Modify the current tree.
modifyLabel :: (a -> a) -> TreeLoc a -> TreeLoc aSource
Modify the label at the current node.
setLabel :: a -> TreeLoc a -> TreeLoc aSource
Change the label at the current node.
getLabel :: TreeLoc a -> aSource
Produced by Haddock version 2.6.0