tracetree-0.1.0.1: Visualize Haskell data structures as edge-labeled trees

Safe HaskellSafe
LanguageHaskell2010

Debug.Trace.Tree.Edged

Contents

Description

Edge-labelled rose trees

Intended to be double imported:

import Debug.Trace.Tree.Edged
import qualified Debug.Trace.Tree.Edged as Edged

Synopsis

Documentation

data ETree k v Source

Tree with nodes labelled with v and arrows labelled with k

Constructors

Node v (Assoc k (ETree k v)) 

Instances

Standard operations

elems :: ETree k v -> [v] Source

keys :: ETree k v -> [k] Source

mapEdges :: (v -> v -> k -> k') -> ETree k v -> ETree k' v Source

Change the edges of the tree, providing source and target

Hiding nodes

class MatchAgainst v m where Source

Abstract definition of something we can match against a value

Methods

matchAgainst :: v -> m -> Bool Source

data NodeSpec v Source

Various ways we can specify a node

Constructors

NodeCoords Coords

Node at the specified coordinates

forall m . (MatchAgainst v m, Show m) => NodeMatch m

Match the value of the node

Instances

data Hide v Source

Specification of nodes to hide

Constructors

HideNode (NodeSpec v)

Hide the specified node

HideMax (Int, Int) (NodeSpec v)

Limit the range of children of the specified node

Instances

hideNodes :: forall k v. [Hide v] -> ETree k (v, Metadata) -> ETree k (Maybe v, Metadata) Source

Annotation

type Depth = Int Source

Depth of a node in the tree

type Offset = Int Source

Offset of a node in the tree

This is the horizontal offset of a node across all nodes at that depth.

For example, the offsets of

    A
   / \
  B   C
 / \   \
D   E   F

are given by

      (A,0)
       / \
   (B,0)  (C,1)
    / \      \
(D,0)  (E,1)  (F,2)

Similarly, the offsets of

  A
 / \
B   C
   / \
  D   E

are given by

   (A,0)
    / \
(B,0) (C,1)
      /   \
  (D,0)   (E,1)

Note that in this second example, D gets number 0 because it's the first node at this level; it's therefore not the case that the nodes with number 0 necessarily make up the _spine_ of the tree.

data Coords Source

Coordinates of a node in the tree

Constructors

Coords 

Fields

depth :: Depth

The "y coordinate" (depth in the tree)

offset :: Offset

The "x coordinate" (across all nodes at this depth)

data Metadata Source

Metadata of a node in the tree

Constructors

Metadata 

Fields

isSpine :: Bool
 
nthChild :: Int
 
coords :: Coords
 

Interaction between ETree and Tree

pushEdges :: k -> ETree k v -> Tree (k, v) Source

Push each edge label to a subtree into the node of that subtree

Since there is no edge to the root of the tree, the "edge" to that root must be passed in as an argument.

pullEdges :: Tree (k, v) -> (k, ETree k v) Source

Inverse of pushEdges

liftTree :: (Tree (k, v) -> Tree ((k, v), b)) -> k -> ETree k v -> ETree k (v, b) Source

Lift an labelling function on trees to edged trees

liftTree' :: (forall a. Tree a -> Tree (a, b)) -> ETree k v -> ETree k (v, b) Source

Variation on liftTree for functions which don't need the edges