aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Main.hs18
-rw-r--r--verifuzz.cabal3
2 files changed, 19 insertions, 2 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 0d49a3c..529c5b0 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -1,7 +1,12 @@
module Main where
import Data.Bits
-import Test.QuickCheck hiding ((.&.), (.|.))
+import Test.QuickCheck hiding ((.&.))
+import Data.GraphViz
+import Data.Graph.Inductive.Example (clr479, dag4)
+import Data.Text.Lazy
+import Data.GraphViz.Printing
+import Data.Graph.Inductive.Graph
type Input = Bool
@@ -34,5 +39,14 @@ eval (Node Xor c1 c2) = eval c1 `xor` eval c2
eval (Node Nand c1 c2) = complement $ eval c1 .&. eval c2
eval (Node Nor c1 c2) = complement $ eval c1 .|. eval c2
+visualize :: (Graph g, Show a) => Circuit a -> g String ()
+visualize circ =
+ uncurry mkGraph $ graph Nothing 0 ([], []) circ
+ where
+ graph (Just (par, _)) nl (n, e) (In val) = (n ++ [(nl, "In: " ++ show val)], e ++ [(par, nl, ())])
+ graph Nothing nl (n, e) (In val) = (n ++ [(nl, "In: " ++ show val)], e)
+ graph _ _ _ _ = ([], [])
+
main :: IO ()
-main = sample (arbitrary :: Gen (Circuit Input))
+--main = sample (arbitrary :: Gen (Circuit Input))
+main = putStrLn . unpack . renderDot . toDot . graphToDot nonClusteredParams $ visualize (In True)
diff --git a/verifuzz.cabal b/verifuzz.cabal
index ec4ec70..250cbdb 100644
--- a/verifuzz.cabal
+++ b/verifuzz.cabal
@@ -19,3 +19,6 @@ executable verifuzz
default-language: Haskell2010
build-depends: base >= 4.7 && < 5
, QuickCheck
+ , graphviz
+ , fgl
+ , text