
Data.Tree  Portability  portable  Stability  experimental  Maintainer  libraries@haskell.org 





Description 
Multiway trees (aka rose trees) and forests.


Synopsis 



Documentation 

data Tree a 
Multiway trees, also known as rose trees.
 Constructors  Node   rootLabel :: a  label value
 subForest :: (Forest a)  zero or more child trees


 Instances  


type Forest a = [Tree a] 

Twodimensional drawing


drawTree :: Tree String > String 
Neat 2dimensional drawing of a tree.


drawForest :: Forest String > String 
Neat 2dimensional drawing of a forest.


Extraction


flatten :: Tree a > [a] 
The elements of a tree in preorder.


levels :: Tree a > [[a]] 
Lists of nodes at each level of the tree.


Building trees


unfoldTree :: (b > (a, [b])) > b > Tree a 
Build a tree from a seed value


unfoldForest :: (b > (a, [b])) > [b] > Forest a 
Build a forest from a list of seed values


unfoldTreeM :: Monad m => (b > m (a, [b])) > b > m (Tree a) 
Monadic tree builder, in depthfirst order


unfoldForestM :: Monad m => (b > m (a, [b])) > [b] > m (Forest a) 
Monadic forest builder, in depthfirst order


unfoldTreeM_BF :: Monad m => (b > m (a, [b])) > b > m (Tree a) 
Monadic tree builder, in breadthfirst order,
using an algorithm adapted from
BreadthFirst Numbering: Lessons from a Small Exercise in Algorithm Design,
by Chris Okasaki, ICFP'00.


unfoldForestM_BF :: Monad m => (b > m (a, [b])) > [b] > m (Forest a) 
Monadic forest builder, in breadthfirst order,
using an algorithm adapted from
BreadthFirst Numbering: Lessons from a Small Exercise in Algorithm Design,
by Chris Okasaki, ICFP'00.


Produced by Haddock version 0.7 