Copyright | (c) The University of Glasgow 2002 |
---|---|

License | BSD-style (see the file libraries/base/LICENSE) |

Maintainer | libraries@haskell.org |

Portability | portable |

Safe Haskell | Trustworthy |

Language | Haskell98 |

Multi-way trees (*aka* rose trees) and forests.

- data Tree a = Node {}
- type Forest a = [Tree a]
- drawTree :: Tree String -> String
- drawForest :: Forest String -> String
- flatten :: Tree a -> [a]
- levels :: Tree a -> [[a]]
- foldTree :: (a -> [b] -> b) -> Tree a -> b
- unfoldTree :: (b -> (a, [b])) -> b -> Tree a
- unfoldForest :: (b -> (a, [b])) -> [b] -> Forest a
- unfoldTreeM :: Monad m => (b -> m (a, [b])) -> b -> m (Tree a)
- unfoldForestM :: Monad m => (b -> m (a, [b])) -> [b] -> m (Forest a)
- unfoldTreeM_BF :: Monad m => (b -> m (a, [b])) -> b -> m (Tree a)
- unfoldForestM_BF :: Monad m => (b -> m (a, [b])) -> [b] -> m (Forest a)

# Documentation

Multi-way trees, also known as *rose trees*.

Monad Tree Source # | |

Functor Tree Source # | |

Applicative Tree Source # | |

Foldable Tree Source # | |

Traversable Tree Source # | |

Eq1 Tree Source # | |

Ord1 Tree Source # | |

Read1 Tree Source # | |

Show1 Tree Source # | |

MonadZip Tree Source # | |

Eq a => Eq (Tree a) Source # | |

Data a => Data (Tree a) Source # | |

Read a => Read (Tree a) Source # | |

Show a => Show (Tree a) Source # | |

Generic (Tree a) Source # | |

NFData a => NFData (Tree a) Source # | |

Generic1 * Tree Source # | |

type Rep (Tree a) Source # | |

type Rep1 * Tree Source # | |

# Two-dimensional drawing

# Extraction

# Building trees

unfoldTree :: (b -> (a, [b])) -> b -> Tree a Source #

Build a tree from a seed value

unfoldForest :: (b -> (a, [b])) -> [b] -> Forest a Source #

Build a forest from a list of seed values

unfoldTreeM :: Monad m => (b -> m (a, [b])) -> b -> m (Tree a) Source #

Monadic tree builder, in depth-first order

unfoldForestM :: Monad m => (b -> m (a, [b])) -> [b] -> m (Forest a) Source #

Monadic forest builder, in depth-first order

unfoldTreeM_BF :: Monad m => (b -> m (a, [b])) -> b -> m (Tree a) Source #

Monadic tree builder, in breadth-first order,
using an algorithm adapted from
*Breadth-First 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) Source #

Monadic forest builder, in breadth-first order,
using an algorithm adapted from
*Breadth-First Numbering: Lessons from a Small Exercise in Algorithm Design*,
by Chris Okasaki, *ICFP'00*.