news

dotgen provides a a simple interface for generating .dot graph files. It is now available in Fedora. Install it along with graphviz using:

 $ sudo yum install ghc-dotgen-devel graphviz

A binary search tree example is shown below:

module Main where

import Text.Dot

box label = node $ [ ("shape","record"),("height",".1"),("label",label) ]

main = putStrLn $ showDot $ do
     c0 <- box "<f0> |<f1> G|<f2> "
     c1 <- box "<f0> |<f1> E|<f2> "
     c2 <- box "<f0> |<f1> B|<f2> "
     c3 <- box "<f0> |<f1> F|<f2> "
     c4 <- box "<f0> |<f1> R|<f2> "
     c5 <- box "<f0> |<f1> H|<f2> "
     c6 <- box "<f0> |<f1> Y|<f2> "
     c7 <- box "<f0> |<f1> A|<f2> "
     c8 <- box "<f0> |<f1> C|<f2> "

     c0 .->. c4
     c0 .->. c1
     c1 .->. c2
     c1 .->. c3
     c2 .->. c8
     c2 .->. c7
     c4 .->. c6
     c4 .->. c5

     return ()

Compile, and run it using:

$ ghc --make Test.hs
[1 of 1] Compiling Main             ( Test.hs, Test.o )
Linking Test ...

$ ./Test > test.dot

You can convert the generated .dot graph file into .png using:

$ dot -Tpng test.dot -o test.png

A screenshot of the generated png:

binary search tree screenshot