aboutsummaryrefslogtreecommitdiffstats
path: root/src/VeriFuzz/Random.hs
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2019-02-01 20:33:47 +0000
committerYann Herklotz <ymherklotz@gmail.com>2019-02-01 20:33:47 +0000
commit2b690485436b1d4df3c9212a928a1557562fb378 (patch)
tree4e1275166222b71627d97955213cbcde83154161 /src/VeriFuzz/Random.hs
parent157559045f477e443a3f965af6a1959f59930eb8 (diff)
downloadverismith-2b690485436b1d4df3c9212a928a1557562fb378.tar.gz
verismith-2b690485436b1d4df3c9212a928a1557562fb378.zip
Fix all the compile and test errors
Diffstat (limited to 'src/VeriFuzz/Random.hs')
-rw-r--r--src/VeriFuzz/Random.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/VeriFuzz/Random.hs b/src/VeriFuzz/Random.hs
index a6684dd..9cfb570 100644
--- a/src/VeriFuzz/Random.hs
+++ b/src/VeriFuzz/Random.hs
@@ -18,6 +18,7 @@ import Data.Graph.Inductive.PatriciaTree (Gr)
import Data.List (nub)
import Test.QuickCheck (Arbitrary, Gen)
import qualified Test.QuickCheck as QC
+import VeriFuzz.Circuit
dupFolder :: (Eq a, Eq b) => Context a b -> [Context a b] -> [Context a b]
dupFolder cont ns = unique cont : ns
@@ -27,6 +28,10 @@ dupFolder cont ns = unique cont : ns
rDups :: (Eq a, Eq b) => Gr a b -> Gr a b
rDups g = G.buildGr $ G.ufold dupFolder [] g
+-- | Remove duplicates.
+rDupsCirc :: Circuit -> Circuit
+rDupsCirc = Circuit . rDups . getCircuit
+
-- | Gen instance to create an arbitrary edge, where the edges are limited by
-- `n` that is passed to it.
arbitraryEdge :: (Arbitrary e) => Int -> Gen (LEdge e)
@@ -52,3 +57,7 @@ randomDAG = do
-- | Generate a random acyclic DAG with an IO instance.
genRandomDAG :: (Arbitrary l, Arbitrary e, Eq l, Eq e) => IO (Gr l e)
genRandomDAG = QC.generate randomDAG
+
+-- | Generate a random circuit instead of a random graph
+randomCircuit :: Gen Circuit
+randomCircuit = Circuit <$> randomDAG