diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2015-06-14 20:35:08 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2015-06-14 20:35:08 +0200 |
commit | e92c82e2c9ff541cd321ad7a8aedcf34e615197c (patch) | |
tree | fd07d24164450f25a224eb593922e4a4926d062b /src/Codec/Pesto/Dot.lhs | |
download | pesto-e92c82e2c9ff541cd321ad7a8aedcf34e615197c.tar.gz pesto-e92c82e2c9ff541cd321ad7a8aedcf34e615197c.tar.bz2 pesto-e92c82e2c9ff541cd321ad7a8aedcf34e615197c.zip |
First public version
Diffstat (limited to 'src/Codec/Pesto/Dot.lhs')
-rw-r--r-- | src/Codec/Pesto/Dot.lhs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Codec/Pesto/Dot.lhs b/src/Codec/Pesto/Dot.lhs new file mode 100644 index 0000000..a0ac161 --- /dev/null +++ b/src/Codec/Pesto/Dot.lhs @@ -0,0 +1,24 @@ +Presentation +------------ + +.. class:: nodoc + +> module Codec.Pesto.Dot (toDot) where +> import Codec.Pesto.Serialize (serialize) + +Since each recipe is just a directed graph (digraph), we can use the dot +language to represent it as well. This in turnXXX can be transformed into an +image, for example. + +> toDot nodes edges = unlines $ ["digraph a {\nnode [fontname=\"Roboto Semi-Light\"];"] ++ n ++ e ++ ["}"] +> where +> f (a, b) = show a ++ " -> " ++ show b ++ ";" +> e = map f edges +> n = map (\(a, b) -> show a ++ " [label=\"" ++ dotEncodeString (serialize b) ++ "\"];") nodes +> addcolor = "#e6ee9c" + +> dotEncodeString = concatMap dotEncodeChar +> dotEncodeChar '\n' = "\\n" +> dotEncodeChar '"' = "\\\"" +> dotEncodeChar x = [x] + |