Copyright | (c) Nathan Bedell 2021 |
---|---|
License | MIT |
Maintainer | nbedell@tulane.edu |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module contains the definition of a simple rose-tree-like datatype, parameterized by
both the type of the labels for the branches, the type of elements contained
in the leaves of the datatype, and the type f
of containers used for the branching: Tree b f a
.
Fixing the type of labels (usually b ~ ()
for simplicity), we have instances for
Functor, Applicative, Monad, and Alternative. This is similar to the list monad, but because
the underlying datastructure is a tree, and we can represent branchind non-determinism,
there is more flexibility -- as when trying to extract data from a Tree
, one can choose
a search strategy for flattening the tree.
This module provides a simple breadth-first-search strategy bfs
, and a depth-first
strategy dfs
, however, theoretically other strategies could be used, taking advantage
of the information provided by the type of labels b
for the tree. For instance, with
b ~ Double
, a best-first or probabilistic search could be used.
Tree data type
Simple rose-tree data structure, with labels of
type n
for nodel, labels of types b
for branches, containers of type f
used to branch on tree nodes, and values of type a
at the leaves.
f
will usually be []
, but this was kept generic to allow for
the use of more efficent containers if relevant.