Portability | portable |
---|---|
Stability | experimental |
Maintainer | Uwe Schmidt (uwe\@fh-wedel.de) |
Interface definition for trees
- class Tree t where
- mkTree :: a -> [t a] -> t a
- mkLeaf :: a -> t a
- isLeaf :: t a -> Bool
- isInner :: t a -> Bool
- getNode :: t a -> a
- getChildren :: t a -> [t a]
- changeNode :: (a -> a) -> t a -> t a
- changeChildren :: ([t a] -> [t a]) -> t a -> t a
- setNode :: a -> t a -> t a
- setChildren :: [t a] -> t a -> t a
- foldTree :: (a -> [b] -> b) -> t a -> b
- nodesTree :: t a -> [a]
- depthTree :: t a -> Int
- cardTree :: t a -> Int
- formatTree :: (a -> String) -> t a -> String
Documentation
The interface for trees
mkTree :: a -> [t a] -> t aSource
tree construction: a new tree is constructed by a node attribute and a list of children
leaf construction: leafs don't have any children
definition: mkLeaf n = mkTree n []
leaf test: list of children empty?
innner node test: not . isLeaf
select node attribute
getChildren :: t a -> [t a]Source
select children
changeNode :: (a -> a) -> t a -> t aSource
edit node attribute
changeChildren :: ([t a] -> [t a]) -> t a -> t aSource
edit children
setNode :: a -> t a -> t aSource
substitute node: setNode n = changeNode (const n)
setChildren :: [t a] -> t a -> t aSource
substitute children: setChildren cl = changeChildren (const cl)
foldTree :: (a -> [b] -> b) -> t a -> bSource
fold for trees
all nodes of a tree
depth of a tree
number of nodes in a tree
formatTree :: (a -> String) -> t a -> StringSource
format tree for readable trace output
a graphical representation of the tree in text format
Tree NTree | Implementation of Data.Tree.Class interface for rose trees |