graph - Generating diagram of Haskell data structures -


i searching tool that, given file several data structures in haskell, able generate diagram relationships between data structures.

i have file parse tree (+- 600 lines) , i'd see parse tree more visually. options?

thanks in advance.

one option use diagrams library, has variety of backends. diagrams-contrib package includes auxiliary functions rendering trees. perhaps convert parse tree rose tree data.tree , render in way.

the following example uses svg backend:

module treeish  -- example requires containers,  -- diagrams-core, diagrams-lib, diagrams-contrib , diagrams-svg packages import data.tree import diagrams.prelude  import diagrams.twod.layout.tree (rendertree,symmlayout',_slhsep,_slvsep) import diagrams.backend.svg (svg) import diagrams.backend.svg.cmdline (defaultmain)  exampletree :: tree string exampletree = node "a" [node "b" [], node "c" []]  rendernodetree :: tree string -> qdiagram svg v2 double rendernodetree nodetree = rendertree      (\a -> letter `atop` square 1.03 # fc white)      (~~)      (symmlayout' (with{ _slhsep = 3,  _slvsep = 2}) nodetree)        letter = text # font "monospace" # fontsize (local 0.47)   main :: io () main = defaultmain (rendernodetree exampletree) 

rendertree function that, given function creates diagram tree node, , function creates line between 2 given points, returns function creates diagram out of tree has been annotated node positions.

the position annotations added using symmlayout' function.

with synonym default data.default.

(~~) creates line between 2 points.

when program run command line (with runhaskell treeish -o foo.svg -w 300) generate svg file can viewed in browser:

enter image description here

here , here 2 parts of recent tutorial on diagrams.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

methods - python can't use function in submodule -

c# - ErrorThe type or namespace name 'AxWMPLib' could not be found (are you missing a using directive or an assembly reference?) -