Zora-1.1.10: Graphing library wrapper + assorted useful functions

Portabilityportable
Stabilityexperimental
Maintainerbgwines@cs.stanford.edu
Safe HaskellNone

Zora.Graphing.DAGGraphing

Description

A typeclass with default implementation for graphing trees with Haskell GraphViz. It is intended to be extremely straightforward to graph your data type; you only need to define three very simple functions (example implementations below).

Synopsis

Documentation

class DAGGraphable g whereSource

A typeclass for tree-like algebraic data types that are able to be graphed.

For these descriptions, assume the following example data type:

 data Tree a = Empty | Leaf a | Node a (Tree a) (Tree a)

Methods

expand :: g -> Maybe (Maybe String, [(Maybe String, g)])Source

Expands a node into its show_node and children. For example,

 expand (Empty) = Nothing
 expand (Leaf x) = Just (x, [])
 expand (Node x l r) = Just (x, [("L child", l), ("R child", r)])

graph :: (Eq g, Show g, DAGGraphable g) => g -> IO StringSource

Graphs the given DAGGraphable data type. Output is written to a file named "graph-i.dot", where i is the successor of the highest i-show_node of all existing "graph-i.dot" files in the current directory.You won't need to override this implementation.

zoldMap :: (Monoid m, DAGGraphable g) => (g -> m) -> g -> mSource

A default implementation of zoldMap -- being instance of DAGGraphable is enough to make your data type an instance of Zoldable (in Zora.Types). You shouldn't need to override this implementation; just define

 instance Zoldable Tree where
 	zoldMap :: (Monoid m) => (Tree a -> m) -> Tree a -> m
 	zoldMap = G.zoldMap