|
| Moltap.Util.TreeZipper | | Portability | portable | | Stability | experimental | | Maintainer | twanvl@gmail.com |
|
|
|
|
|
| Description |
| A labeled tree data type, and a zipper over that type.
|
|
| Synopsis |
|
|
|
|
| Trees
|
|
| data Tree l a |
| A tree. Edges are labled with type l and nodes store values of type a
| | Constructors | | Instances | |
|
|
| type LabeledForest l a = Seq (LabeledTree l a) |
|
| data LabeledTree l a |
| Constructors | | Instances | |
|
|
| toGraph :: Tree l a -> [(Int, a, [(Int, l)])] |
Convert a tree to a graph.
A graph consists of nodes (named with integers) and outgoing edges for each node.
The root will have key 0.
|
|
| singleton :: a -> Tree l a |
| A singleton tree
|
|
| Tree zipper
|
|
| data TreeZipper l a |
| A zipper in a labeled tree.
Maintains a current node, from which we can move in various directions.
| Instances | |
|
|
| toTree :: TreeZipper l a -> Tree l a |
| Extract a tree from a zipper.
For a zipper not at the root returns the subtree for the current node.
|
|
| fromTree :: Tree l a -> TreeZipper l a |
| Construct a TreeZipper from a Tree
|
|
| fromRoot :: a -> TreeZipper l a |
| A singleton TreeZipper
|
|
| Properties
|
|
| isRoot :: TreeZipper l a -> Bool |
| Is a zipper at the root?
|
|
| getValue :: TreeZipper l a -> a |
| Get the value of the current node
|
|
| getLabel :: TreeZipper l a -> l |
| Get the label of the current node, can not be used at the root
|
|
| setValue :: a -> TreeZipper l a -> TreeZipper l a |
| Set the value of the current node
|
|
| setLabel :: l -> TreeZipper l a -> TreeZipper l a |
| Set the label of the current node, can not be used at the root
|
|
| Movement
|
|
| up :: TreeZipper l a -> TreeZipper l a |
| Move up the tree, fails if the zipper is at the root
|
|
| downNew :: l -> a -> TreeZipper l a -> TreeZipper l a |
| Move down the tree, constructing a new node
|
|
| downFirst :: TreeZipper l a -> Maybe (TreeZipper l a) |
| Move down the tree, to the first (rightmost) node
|
|
| next :: TreeZipper l a -> Maybe (TreeZipper l a) |
| Move to the next node, if there is any
|
|
| root :: TreeZipper l a -> TreeZipper l a |
| Move to the root of a zipper
|
|
| data NodeName |
| The name of a node, after moving up the tree it is possible to move down to this node again
|
|
|
| name :: TreeZipper l a -> NodeName |
| Name of the current position in the tree. Not valid at the root
|
|
| downTo :: NodeName -> TreeZipper l a -> TreeZipper l a |
| Move down the tree to a node whos name was queried before moving up
|
|
| Produced by Haddock version 0.8 |