Module

Data.Tree

Package
purescript-tree-rose
Repository
jordanmartinez/purescript-tree-rose

#Tree Source

type Tree a = Cofree List a

A Rose, or multi-way tree, with values of type a. To access the root of the Tree's value, use Control.Comonad.Cofree (head). To access the root's children, use Control.Comonad.Cofree (tail)

#Forest Source

type Forest a = List (Tree a)

A type alias for the children of a Tree's root value.

#mkTree Source

mkTree :: forall a. a -> Forest a -> Tree a

Create a Tree from a Node value of type a and a Forest of children.

#drawTree Source

drawTree :: Tree String -> String

Draw a 2D String representation of a Tree String.

#drawTree' Source

drawTree' :: Int -> Tree String -> String

Draw a 2D String representation of a Tree String, starting the indent at the given level

#drawForest Source

drawForest :: Forest String -> String

Draw a 2D String representation of a Forest String,

#drawForest' Source

drawForest' :: Int -> Forest String -> String

Draw a 2D String representation of a Forest String, starting the indent at the given level

#showTree Source

showTree :: forall a. Show a => Tree a -> String

Draw a 2D String representation of a Tree composed of Showable elements.

#showForest Source

showForest :: forall a. Show a => Forest a -> String

Draw a 2D String representation of a Forest composed of Showable elements.

#scanTree Source

scanTree :: forall a b. (a -> b -> b) -> b -> Tree a -> Tree b

Scan a Tree, accumulating values of b there are constant across Nodes that have the same parent.

#scanTreeAccum Source

scanTreeAccum :: forall a b c. (a -> b -> Accum b c) -> b -> Tree a -> Tree c

Scan a Tree, accumulating values of b there are constant across Nodes that have the same parent, and returning a Tree of type c.

#setNodeValue Source

setNodeValue :: forall a. a -> Tree a -> Tree a

Set the value of a node.

#modifyNodeValue Source

modifyNodeValue :: forall a. (a -> a) -> Tree a -> Tree a

Modify the value of a node.

#appendChild Source

appendChild :: forall a. Tree a -> Tree a -> Tree a

Append a child to a node.