aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-10-29 12:33:50 +0000
committerYann Herklotz <ymherklotz@gmail.com>2018-10-29 12:33:50 +0000
commit796ea5d8f5d6ea422fbb1fbe29621abd7a9f2161 (patch)
tree2de094c6c3a969a5dfe32c2ce130afd812e75479 /src
parent1f43e82274e095e31ca5c575cc358b91982bfc45 (diff)
downloadverismith-796ea5d8f5d6ea422fbb1fbe29621abd7a9f2161.tar.gz
verismith-796ea5d8f5d6ea422fbb1fbe29621abd7a9f2161.zip
Add case to make it more readable
Diffstat (limited to 'src')
-rw-r--r--src/Main.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/Main.hs b/src/Main.hs
index aabff1c..ffbef9a 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -40,14 +40,19 @@ 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 :: (Show a) => Circuit a -> Gr String ()
+visualize :: (Show a) => Circuit a -> Gr String 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 _ _ _ _ = ([], [])
+ graph parent nl (l, e) circ =
+ case (parent, circ) of
+ (Nothing, (In val)) ->
+ ((nl, "In: " ++ show val) : l, e)
+ (Just par, (In val)) ->
+ ((nl, "In: " ++ show val) : l, (par, nl, "") : e)
+ _ ->
+ ([], [])
main :: IO ()
--main = sample (arbitrary :: Gen (Circuit Input))
-main = putStrLn . unpack . renderDot . toDot . graphToDot nonClusteredParams $ visualize (In True)
+main = preview $ visualize (In True)