moltapContentsIndex
Moltap.Util.TreeZipper
Portabilityportable
Stabilityexperimental
Maintainertwanvl@gmail.com
Contents
Trees
Tree zipper
Properties
Movement
Description
A labeled tree data type, and a zipper over that type.
Synopsis
data Tree l a = Branch {
branchValue :: a
subTree :: (LabeledForest l a)
}
type LabeledForest l a = Seq (LabeledTree l a)
data LabeledTree l a = Edge l (Tree l a)
toGraph :: Tree l a -> [(Int, a, [(Int, l)])]
singleton :: a -> Tree l a
data TreeZipper l a
toTree :: TreeZipper l a -> Tree l a
fromTree :: Tree l a -> TreeZipper l a
fromRoot :: a -> TreeZipper l a
isRoot :: TreeZipper l a -> Bool
getValue :: TreeZipper l a -> a
getLabel :: TreeZipper l a -> l
setValue :: a -> TreeZipper l a -> TreeZipper l a
setLabel :: l -> TreeZipper l a -> TreeZipper l a
up :: TreeZipper l a -> TreeZipper l a
downNew :: l -> a -> TreeZipper l a -> TreeZipper l a
downFirst :: TreeZipper l a -> Maybe (TreeZipper l a)
next :: TreeZipper l a -> Maybe (TreeZipper l a)
root :: TreeZipper l a -> TreeZipper l a
data NodeName
name :: TreeZipper l a -> NodeName
downTo :: NodeName -> TreeZipper l a -> TreeZipper l a
Trees
data Tree l a
A tree. Edges are labled with type l and nodes store values of type a
Constructors
Branch
branchValue :: a
subTree :: (LabeledForest l a)
show/hide Instances
Foldable (Tree l)
Functor (Tree l)
Traversable (Tree l)
(Eq a, ??? a l) => Eq (Tree l a)
(Ord a, ??? a l) => Ord (Tree l a)
(Show l, Show a) => Show (Tree l a)
type LabeledForest l a = Seq (LabeledTree l a)
data LabeledTree l a
Constructors
Edge l (Tree l a)
show/hide Instances
Foldable (LabeledTree l)
Functor (LabeledTree l)
Traversable (LabeledTree l)
(Eq l, ??? a l) => Eq (LabeledTree l a)
(Ord l, ??? a l) => Ord (LabeledTree l a)
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.
show/hide Instances
Functor (TreeZipper l)
??? a l => Eq (TreeZipper l a)
(Show l, Show a) => Show (TreeZipper l a)
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