hxt-9.3.1.16: A collection of tools for processing XML with Haskell.

CopyrightCopyright (C) 2005 Uwe Schmidt
LicenseMIT
MaintainerUwe Schmidt (uwe\@fh-wedel.de)
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell98

Data.Tree.Class

Description

Interface definition for trees

Synopsis

Documentation

class Tree t where #

The interface for trees

Methods

mkTree :: a -> [t a] -> t a #

tree construction: a new tree is constructed by a node attribute and a list of children

mkLeaf :: a -> t a #

leaf construction: leafs don't have any children

definition: mkLeaf n = mkTree n []

isLeaf :: t a -> Bool #

leaf test: list of children empty?

isInner :: t a -> Bool #

innner node test: not . isLeaf

getNode :: t a -> a #

select node attribute

getChildren :: t a -> [t a] #

select children

changeNode :: (a -> a) -> t a -> t a #

edit node attribute

changeChildren :: ([t a] -> [t a]) -> t a -> t a #

edit children

setNode :: a -> t a -> t a #

substitute node: setNode n = changeNode (const n)

setChildren :: [t a] -> t a -> t a #

substitute children: setChildren cl = changeChildren (const cl)

foldTree :: (a -> [b] -> b) -> t a -> b #

fold for trees

nodesTree :: t a -> [a] #

all nodes of a tree

depthTree :: t a -> Int #

depth of a tree

cardTree :: t a -> Int #

number of nodes in a tree

formatTree :: (a -> String) -> t a -> String #

format tree for readable trace output

a graphical representation of the tree in text format

Instances

Tree NTree #

Implementation of Data.Tree.Class interface for rose trees

Methods

mkTree :: a -> [NTree a] -> NTree a #

mkLeaf :: a -> NTree a #

isLeaf :: NTree a -> Bool #

isInner :: NTree a -> Bool #

getNode :: NTree a -> a #

getChildren :: NTree a -> [NTree a] #

changeNode :: (a -> a) -> NTree a -> NTree a #

changeChildren :: ([NTree a] -> [NTree a]) -> NTree a -> NTree a #

setNode :: a -> NTree a -> NTree a #

setChildren :: [NTree a] -> NTree a -> NTree a #

foldTree :: (a -> [b] -> b) -> NTree a -> b #

nodesTree :: NTree a -> [a] #

depthTree :: NTree a -> Int #

cardTree :: NTree a -> Int #

formatTree :: (a -> String) -> NTree a -> String #

Tree NTZipper # 

Methods

mkTree :: a -> [NTZipper a] -> NTZipper a #

mkLeaf :: a -> NTZipper a #

isLeaf :: NTZipper a -> Bool #

isInner :: NTZipper a -> Bool #

getNode :: NTZipper a -> a #

getChildren :: NTZipper a -> [NTZipper a] #

changeNode :: (a -> a) -> NTZipper a -> NTZipper a #

changeChildren :: ([NTZipper a] -> [NTZipper a]) -> NTZipper a -> NTZipper a #

setNode :: a -> NTZipper a -> NTZipper a #

setChildren :: [NTZipper a] -> NTZipper a -> NTZipper a #

foldTree :: (a -> [b] -> b) -> NTZipper a -> b #

nodesTree :: NTZipper a -> [a] #

depthTree :: NTZipper a -> Int #

cardTree :: NTZipper a -> Int #

formatTree :: (a -> String) -> NTZipper a -> String #

formatNTree' :: Tree t => (a -> String) -> (String -> String) -> (String -> String) -> t a -> String -> String #

convert a tree into a pseudo graphical string representation