Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Tools for working with the TreeDiagram
monoid to draw tree diagrams.
Synopsis
- data TreeDiagram
- showTreeDiagram :: TreeDiagram -> ShowS
- printTreeDiagram :: TreeDiagram -> IO ()
- singleton :: Show a => a -> TreeDiagram
- subtree :: TreeDiagram -> TreeDiagram
- width :: TreeDiagram -> Int
- height :: TreeDiagram -> Int
Documentation
data TreeDiagram Source #
A monoid for generating tree diagrams
Instances
Monoid TreeDiagram Source # |
|
Defined in Data.Monoid.TreeDiagram mempty :: TreeDiagram # mappend :: TreeDiagram -> TreeDiagram -> TreeDiagram # mconcat :: [TreeDiagram] -> TreeDiagram # | |
Semigroup TreeDiagram Source # |
|
Defined in Data.Monoid.TreeDiagram (<>) :: TreeDiagram -> TreeDiagram -> TreeDiagram # sconcat :: NonEmpty TreeDiagram -> TreeDiagram # stimes :: Integral b => b -> TreeDiagram -> TreeDiagram # |
showTreeDiagram :: TreeDiagram -> ShowS Source #
render a tree diagram as a function that prepends a multi-line string
printTreeDiagram :: TreeDiagram -> IO () Source #
print a tree diagram
singleton :: Show a => a -> TreeDiagram Source #
draw a value as a simple, single-line tree diagram
>>>
printTreeDiagram $ singleton 'a'
'a'
subtree :: TreeDiagram -> TreeDiagram Source #
Move a tree diagram to the subtree level, dropping a line down from the graph line to connect it to the new toplevel.
>>>
printTreeDiagram $ subtree (singleton 'a') <> singleton 'b' <> subtree (singleton 'c')
┌─'b'─┐ │ │ 'a' 'c'>>>
printTreeDiagram $ subtree mempty
╷ │ ╵
width :: TreeDiagram -> Int Source #
Full width of a tree diagram
>>>
let d = singleton 'a' <> subtree (subtree (singleton 'b') <> singleton 'c')
>>>
printTreeDiagram d
'a'───┐ │ ┌─'c' │ 'b'>>>
width d
9
height :: TreeDiagram -> Int Source #
Full height of a tree diagram
>>>
let d = singleton 'a' <> subtree (subtree (singleton 'b') <> singleton 'c')
>>>
printTreeDiagram d
'a'───┐ │ ┌─'c' │ 'b'>>>
height d
5