パーサーから直接書き出すようにしたいが、とりあえず。
import Data.Graph.Inductive
import Data.Graph.Inductive.Graphviz
labUEdges :: [Edge] -> [UEdge]
labUEdges = map (\(i,j) -> (i,j,()))
exprt :: Gr String ()
exprt = mkGraph (zip [1..5] ["2","*","3","+","4"])
(labUEdges [(2,1),(2,3),(4,2),(4,5)])
main = do putStrLn $ graphviz exprt "test" (0,0) (0,0) Portrait
コンパイルするには--makeオプションをつけて
$ ghc gvtest.hs --make
[1 of 1] Compiling Main ( gvtest.hs, gvtest.o )
Linking gvtest ...
$ ./gvtest | dot -Tpng > gvtest.png; open gvtest.png