repr-tree-syb-0.1.1: Tree representation and pretty-printing of data structures based on SYB

Safe HaskellNone
LanguageHaskell98

ReprTree

Synopsis

Documentation

reprTree :: Data a => a -> Tree String Source #

Get a representation tree of a generic data structure using SYB. Can be used to implement a custom converter to textual representation.

reprTreeString :: Data a => a -> String Source #

A data representation in form of a formatted multiline string, such as the following:

:
- A
| - :
| | - a
| | - b
| | - c
| - 9
- C
| - 3
- B
- D
  - :
    - :
    | - asdf
    | - 123
    | - ldskfjkl
    - :
      - f

Which is a result of running the following code:

import Data.Generics (Data, Typeable)

data SomeType = 
  A [String] Int | 
  B | 
  C Int | 
  D [[String]]
  deriving (Typeable, Data)

xxx = A ["a", "b", "c"] 9 
    : C 3 
    : B 
    : D [["asdf", "123", "ldskfjkl"], ["f"]]
    : []

main = putStrLn $ reprTreeString xxx