For convenient analysis of data I’d like to use a library which for the following code:
data SomeType = A [String] Int | B | C Int deriving (Eq, Ord, Show)
main = do
let theData = A ["a", "b", "c"] 9 : C 3 : B : []
putStr $ treeString theData -- `treeString` is the implied library function
would produce an output similar to the following:
- A:
| - - a
| | - b
| | - c
| - 9
- C:
| - 3
- B
Is there such a library? Or maybe a better approach to such a problem?
Data.TreehasdrawTreeanddrawForestfunctions with similar formatting, so you can write a function to convert your data structure to aTree Stringand then usedrawTree.Output: