Module

Data.Tree.Zipper

#Loc

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 Locations 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

#next

next :: forall a. Loc a -> Maybe (Loc a)

Move the cursor to the next sibling.

#prev

prev :: forall a. Loc a -> Maybe (Loc a)

#first

first :: forall a. Loc a -> Loc a

#last

last :: forall a. Loc a -> Loc a

#up

up :: forall a. Loc a -> Maybe (Loc a)

#root

root :: forall a. Loc a -> Loc a

Move the cursor to the root of the tree.

#firstChild

firstChild :: forall a. Loc a -> Maybe (Loc a)

Move the cursor to the first child of the current Node.

#down

down :: forall a. Loc a -> Maybe (Loc a)

Move the cursor to the first child of the current Node.

#lastChild

lastChild :: forall a. Loc a -> Maybe (Loc a)

Move the cursor to the last child of the current Node.

#siblingAt

siblingAt :: forall a. Int -> Loc a -> Maybe (Loc a)

Move the cursor to a specific sibling by it's index.

#childAt

childAt :: forall a. Int -> Loc a -> Maybe (Loc a)

Move the cursor to a specific child of the current Node by it's index.

#toTree

toTree :: forall a. Loc a -> Tree a

Retrieve the Tree representation, i.e., returns the root Node of the current tree.

#fromTree

fromTree :: forall a. Tree a -> Loc a

Get a Location representation from a given Tree.

#setNode

setNode :: forall a. Tree a -> Loc a -> Loc a

Set the Node at the current position.

#modifyNode

modifyNode :: forall a. (Tree a -> Tree a) -> Loc a -> Loc a

Set the Node at the current position.

#setValue

setValue :: forall a. a -> Loc a -> Loc a

Set the value of the current Node.

#modifyValue

modifyValue :: forall a. (a -> a) -> Loc a -> Loc a

Modify the value of the current Node.

#insertAfter

insertAfter :: forall a. Tree a -> Loc a -> Loc a

Insert a node after the current position, and move cursor to the new node.

#insertBefore

insertBefore :: forall a. Tree a -> Loc a -> Loc a

Insert a node before the current position, and move cursor to the new node.

#insertChild

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.

#delete

delete :: forall a. Loc a -> Loc a

Delete the node in the current position.

#findDownWhere

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

#findDown

findDown :: forall a. Eq a => a -> Loc a -> Maybe (Loc a)

Search for the first occurence of the value a downwards and to the right.

#findUpWhere

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

#findUp

findUp :: forall a. Eq a => a -> Loc a -> Maybe (Loc a)

Search for the first occurence of the value a upwards and to the left,

#findFromRootWhere

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

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.

#flattenLocDepthFirst

flattenLocDepthFirst :: forall a. Loc a -> List (Loc a)

flattens the Tree into a List depth first.

#node

node :: forall a. Loc a -> Tree a

#value

value :: forall a. Loc a -> a

#before

before :: forall a. Loc a -> Forest a

#after

after :: forall a. Loc a -> Forest a

#parents

parents :: forall a. Loc a -> List (Loc a)

#children

children :: forall a. Loc a -> Forest a

#siblings

siblings :: forall a. Loc a -> Forest a

Modules