Data.Tree.Zipper
- Package
- purescript-tree-rose
- Repository
- jordanmartinez/purescript-tree-rose
#Loc Source
newtype Loc a
The Loc
type describes the location of a Node
inside a Tree
. For this
we store the current Node
, the sibling nodes that appear before the current
node, the sibling nodes that appear after the current node, and a List
of
Loc
ations that store the parent node locations up to the root of the three.
So, effectively, the parents
field records the path travelled in the
tree to reach the level of the current Node
starting from the tree's root,
and the before
and after
fields describe its location in the current
level.
Constructors
Instances
#firstChild Source
firstChild :: forall a. Loc a -> Maybe (Loc a)
Move the cursor to the first child of the current Node
.
#modifyNode Source
modifyNode :: forall a. (Tree a -> Tree a) -> Loc a -> Loc a
Set the Node
at the current position.
#modifyValue Source
modifyValue :: forall a. (a -> a) -> Loc a -> Loc a
Modify the value of the current Node
.
#insertAfter Source
insertAfter :: forall a. Tree a -> Loc a -> Loc a
Insert a node after the current position, and move cursor to the new node.
#insertBefore Source
insertBefore :: forall a. Tree a -> Loc a -> Loc a
Insert a node before the current position, and move cursor to the new node.
#insertChild Source
insertChild :: forall a. Tree a -> Loc a -> Loc a
Insert a node as a child to the current node, and move cursor to the new node.
#findDownWhere Source
findDownWhere :: forall a. (a -> Boolean) -> Loc a -> Maybe (Loc a)
Search down and to the right for the first occurence where the given predicate is true and return the Loc
#findUpWhere Source
findUpWhere :: forall a. (a -> Boolean) -> Loc a -> Maybe (Loc a)
Search to the left and up for the first occurence where the given predicate is true and return the Loc
#findFromRootWhere Source
findFromRootWhere :: forall a. (a -> Boolean) -> Loc a -> Maybe (Loc a)
Search from the root of the tree for the first occurrence where the given predicate is truen and return the Loc
#findFromRoot Source
findFromRoot :: forall a. Eq a => a -> Loc a -> Maybe (Loc a)
Search for the first occurence of the value a
starting from the root of
the tree.
- Modules
- Data.
Tree - Data.
Tree. Zipper