bishbosh-0.1.4.0: Plays chess.
Safe HaskellSafe-Inferred
LanguageHaskell2010

BishBosh.Data.RoseTree

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
Defines operations on an arbitrary rose-tree.
Synopsis

Types

Type-synonyms

type IsMatch a = a -> Bool Source #

Whether a datum matches.

Functions

countTerminalNodes :: Num nodes => Tree a -> nodes Source #

Counts the number of terminal nodes.

drawTree :: (a -> String) -> Tree a -> String Source #

Returns a string which graphically represents the tree.

drawForest :: (a -> String) -> Forest a -> String Source #

Returns a string which graphically represents the forest.

traceRoute Source #

Arguments

:: (datum -> IsMatch a)

Whether a datum matches.

-> Tree a 
-> [datum]

The data against which, nodes from the tree should be matched.

-> Maybe [a]

Returns Nothing on match-failure.

Trace a path down the specified tree, of matching nodes.

Mutators

promote Source #

Arguments

:: (datum -> IsMatch a)

Whether a node matches.

-> [datum]

The data against which nodes from the forest should be matched.

-> [Tree a] 
-> Maybe [Tree a]

Returns Nothing on match-failure.

  • Recursively advances the position within the forest, of the first node which matches the next datum, at successively deeper levels.
  • CAVEAT: each datum is expected to match exactly one item from the forest at each level.

reduce :: IsMatch a -> Tree a -> Maybe (Tree a) Source #

Reduce the tree to the first matching datum in the forest.

prune :: Int -> Transformation a Source #

Remove branches after the specified depth.

mapForest :: (a -> Forest a -> Forest a) -> Transformation a Source #

  • Apply an arbitrary mapping to all subForests; cf. fmap which applies an arbitrary function to all rootLabels.
  • The mapping is given access to the label at each forest.