Copyright (c) Tom Smeets BSD3-style (see LICENSE) Tom Smeets unstable unportable Safe-Inferred Haskell98

Description

Zipper over the Data.Tree data structure. This module is based on rosezipper.

Synopsis

# Data structure

data TreeZipper a Source #

A Zipper over the Data.Tree data structure.

Very crappy visualization of the TreeZipper data structure

             (tz_parents)
([*],       *, [*])
([*, *],    *, [])
([],        *                  [*,   *])
|                   |    |
+-------+--------+-------+------+  +-*-+  *
|       |        |       |      |  |   |
(tz_before) (tz_current) (tz_after) *   *
|       |                |      |
+-*-+     *                *      *
|   |
*   *


Constructors

 TreeZipper Fieldstz_current :: Tree athe currently focused sub-tree under the cursortz_before :: Forest aall sub-tree's to the left of the cursor that have the same parenttz_after :: Forest aall sub-tree's to the right of the cursor that have the same parenttz_parents :: [(Forest a, a, Forest a)]list zippers for each parent level, the first element is the current parent

cursor :: TreeZipper a -> a Source #

Get the highlighted value

# Conversion

Create a TreeZipper from a list of Trees focused on the first element

Convert the entire zipper back to a Forest

Create a Forest from all the children of the current parent

Go to the upper most node such that nothing is before nor above the cursor

Move to the parent node

Move the cursor one level down to the first node

Go to the next child node

Go to the previous child node

# Utils

How many nodes are above this one?

How many nodes are before the cursor? (on the current level)

followPath :: Eq b => (a -> b) -> [b] -> TreeZipper a -> Maybe (TreeZipper a) Source #

follow a Path specified by the list of nodes

findChild :: (a -> Bool) -> TreeZipper a -> Maybe (TreeZipper a) Source #

go to the first node next to the cursor that matches

Check whenther this is a leaf node

Check whenther this is a leaf node

Check whenther this the last child

Check whenther this the first child