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

Copyright | Copyright (C) 2005 Uwe Schmidt
License | MIT
Maintainer | Uwe Schmidt (uwe\@fh-wedel.de)
Stability | experimental
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Tree.Class

Description

Interface definition for trees

Synopsis

- class Tree (t :: Type -> Type) 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
- formatNTree' :: Tree t => (a -> String) -> (String -> String) -> (String -> String) -> t a -> String -> String

# Documentation

class Tree (t :: Type -> Type) where Source #

The interface for trees

Minimal complete definition

mkTree, getNode, getChildren, changeNode, changeChildren, foldTree

Methods

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

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

mkLeaf :: a -> t a Source #

leaf construction: leafs don't have any children

definition: `mkLeaf n = mkTree n []`

isLeaf :: t a -> Bool Source #

leaf test: list of children empty?

isInner :: t a -> Bool Source #

innner node test: `not . isLeaf`

getNode :: t a -> a Source #

select node attribute

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

select children

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

edit node attribute

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

edit children

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

substitute node: `setNode n = changeNode (const n)`

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

substitute children: `setChildren cl = changeChildren (const cl)`

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

fold for trees

nodesTree :: t a -> [a] Source #

all nodes of a tree

depthTree :: t a -> Int Source #

depth of a tree

cardTree :: t a -> Int Source #

number of nodes in a tree

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

format tree for readable trace output

a graphical representation of the tree in text format

#### Instances

Instances details

Tree NTree Source # | Implementation of Data.Tree.Class interface for rose trees

Instance details

Defined in Data.Tree.NTree.TypeDefs

Methods

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

mkLeaf :: a -> NTree a Source #

isLeaf :: NTree a -> Bool Source #

isInner :: NTree a -> Bool Source #

getNode :: NTree a -> a Source #

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

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

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

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

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

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

nodesTree :: NTree a -> [a] Source #

depthTree :: NTree a -> Int Source #

cardTree :: NTree a -> Int Source #

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

Tree NTZipper Source # |

Instance details

Defined in Data.Tree.NTree.Zipper.TypeDefs

Methods

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

mkLeaf :: a -> NTZipper a Source #

isLeaf :: NTZipper a -> Bool Source #

isInner :: NTZipper a -> Bool Source #

getNode :: NTZipper a -> a Source #

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

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

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

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

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

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

nodesTree :: NTZipper a -> [a] Source #

depthTree :: NTZipper a -> Int Source #

cardTree :: NTZipper a -> Int Source #

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

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

convert a tree into a pseudo graphical string representation