|
| Data.Generics.Fixplate.Zipper |
|
|
|
|
| Description |
| The Zipper is a data structure which maintains a location in
a tree, and allows O(1) movement and local changes
(to be more precise, in our case it is O(k) where k is the number
of children of the node at question; typically this is a very small number).
|
|
| Synopsis |
|
|
|
|
| Types
|
|
|
| A context node.
|
|
|
| The context or path type. The invariant we must respect is that there is exactly
one child with the Right constructor.
| | Constructors | | Instances | |
|
|
|
| The zipper type itself, which encodes a locations in thre tree Mu f.
| | Constructors | | Instances | |
|
|
| Converting to and from zippers
|
|
|
| Creates a zipper from a tree, with the focus at the root.
|
|
|
| Restores a tree from a zipper.
|
|
|
| We attribute all nodes with a zipper focused at that location.
|
|
|
| The list of all locations.
|
|
|
| The zipper version of forget.
|
|
| Manipulating the subtree at focus
|
|
|
| Extracts the subtree at focus. Synonym of focus.
|
|
|
| Replaces the subtree at focus.
|
|
|
| Modifies the subtree at focus.
|
|
| Safe movements
|
|
|
| Moves down to the child with the given index.
The leftmost children has index 0.
|
|
|
| Moves down to the leftmost child.
|
|
|
| Moves down to the rightmost child.
|
|
|
| Moves up.
|
|
|
|
|
|
| Testing for borders
|
|
|
| Checks whether we are at the top (root).
|
|
|
| Checks whether we cannot move down.
|
|
|
|
|
|
| Location queries
|
|
|
| Gives back the index of the given location among the children of its parent.
Indexing starts from zero. In case of root node (no parent), we also return zero.
|
|
|
We return the full path from the root as a sequence of child indices.
This means that
loc == foldl (flip unsafeMoveDown) (moveTop loc) (fullPathDown loc)
|
|
|
The following equations hold for fullPathUp and fullPathDown:
fullPathUp == reverse . fullPathDown
loc == foldr unsafeMoveDown (moveTop loc) (fullPathUp loc)
|
|
| Compound movements
|
|
|
| Moves to the top, by repeatedly moving up.
|
|
|
| Moves left until it can.
It should be faster than repeated left steps.
|
|
|
| Moves right until it can.
It should be faster than repeated right steps.
|
|
| Unsafe movements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Produced by Haddock version 2.6.1 |