Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Data.Tree.Zipper
- data TreePos t a
- class PosType t
- data Empty a
- data Full a
- before :: PosType t => TreePos t a -> Forest a
- after :: PosType t => TreePos t a -> Forest a
- forest :: PosType t => TreePos t a -> Forest a
- tree :: TreePos Full a -> Tree a
- label :: TreePos Full a -> a
- parents :: PosType t => TreePos t a -> [(Forest a, a, Forest a)]
- fromTree :: Tree a -> TreePos Full a
- fromForest :: Forest a -> TreePos Empty a
- toForest :: PosType t => TreePos t a -> Forest a
- toTree :: TreePos Full a -> Tree a
- parent :: PosType t => TreePos t a -> Maybe (TreePos Full a)
- root :: TreePos Full a -> TreePos Full a
- prevSpace :: TreePos Full a -> TreePos Empty a
- prevTree :: TreePos Empty a -> Maybe (TreePos Full a)
- prev :: PosType t => TreePos t a -> Maybe (TreePos t a)
- first :: TreePos Empty a -> TreePos Empty a
- spaceAt :: Int -> TreePos Empty a -> TreePos Empty a
- nextSpace :: TreePos Full a -> TreePos Empty a
- nextTree :: TreePos Empty a -> Maybe (TreePos Full a)
- next :: PosType t => TreePos t a -> Maybe (TreePos t a)
- last :: TreePos Empty a -> TreePos Empty a
- children :: TreePos Full a -> TreePos Empty a
- firstChild :: TreePos Full a -> Maybe (TreePos Full a)
- lastChild :: TreePos Full a -> Maybe (TreePos Full a)
- childAt :: Int -> TreePos Full a -> Maybe (TreePos Full a)
- isRoot :: PosType t => TreePos t a -> Bool
- isFirst :: PosType t => TreePos t a -> Bool
- isLast :: PosType t => TreePos t a -> Bool
- isLeaf :: TreePos Full a -> Bool
- isContained :: PosType t => TreePos t a -> Bool
- hasChildren :: TreePos Full a -> Bool
- insert :: Tree a -> TreePos Empty a -> TreePos Full a
- delete :: TreePos Full a -> TreePos Empty a
- setTree :: Tree a -> TreePos Full a -> TreePos Full a
- modifyTree :: (Tree a -> Tree a) -> TreePos Full a -> TreePos Full a
- modifyLabel :: (a -> a) -> TreePos Full a -> TreePos Full a
- setLabel :: a -> TreePos Full a -> TreePos Full a
Documentation
Minimal complete definition
_prev, _next, _forest
Position which does not point to a tree (e.g., it is between two trees).
Position which points to a tree.
Context
before :: PosType t => TreePos t a -> Forest a Source #
Siblings before this position, closest first.
forest :: PosType t => TreePos t a -> Forest a Source #
All trees at this location (i.e., the current tree---if any---and its siblings).
parents :: PosType t => TreePos t a -> [(Forest a, a, Forest a)] Source #
The contexts of the parents for this position.
Conversions
fromTree :: Tree a -> TreePos Full a Source #
A location corresponding to the root of the given tree.
Moving around
parent :: PosType t => TreePos t a -> Maybe (TreePos Full a) Source #
The parent of the given location.
prevTree :: TreePos Empty a -> Maybe (TreePos Full a) Source #
The tree before this location, if any.
spaceAt :: Int -> TreePos Empty a -> TreePos Empty a Source #
The empty space at the given index. The first space is at index 0. For indexes that are negative or too large, we return the first and last position in the tree, respectively.
children :: TreePos Full a -> TreePos Empty a Source #
The location at the beginning of the forest of children.
firstChild :: TreePos Full a -> Maybe (TreePos Full a) Source #
The first child of the given location.
childAt :: Int -> TreePos Full a -> Maybe (TreePos Full a) Source #
The child at the given index in the tree. The first child is at index 0.
Node classification
isFirst :: PosType t => TreePos t a -> Bool Source #
Are we the first position (of its kind) in a forest.
isLast :: PosType t => TreePos t a -> Bool Source #
Are we the last position (of its kind) in a forest.
Working with the current tree
insert :: Tree a -> TreePos Empty a -> TreePos Full a Source #
Insert a new tree at the current position.
modifyTree :: (Tree a -> Tree a) -> TreePos Full a -> TreePos Full a Source #
Modify the current tree.