Module

Data.Tree.Zipper

Package
purescript-tree
Repository
dmbfm/purescript-tree

#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 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 Source

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

Move the cursor to the next sibling.

#prev Source

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

#first Source

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

#last Source

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

#up Source

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

#root Source

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

Move the cursor to the root of the tree.

#firstChild Source

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

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

#down Source

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

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

#lastChild Source

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

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

#siblingAt Source

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

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

#childAt Source

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 Source

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

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

#fromTree Source

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

Get a Location representation from a given Tree.

#setNode Source

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

Set the Node at the current position.

#modifyNode Source

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

Set the Node at the current position.

#setValue Source

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

Set the value of the current Node.

#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.

#delete Source

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

Delete the node in the current position.

#findDown Source

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.

#findUp Source

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.

#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.

#node Source

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

#value Source

value :: forall a. Loc a -> a

#before Source

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

#after Source

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

#parents Source

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

#children Source

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

#siblings Source

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