From 2b690485436b1d4df3c9212a928a1557562fb378 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Fri, 1 Feb 2019 20:33:47 +0000 Subject: Fix all the compile and test errors --- src/VeriFuzz/Random.hs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/VeriFuzz/Random.hs') 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 -- cgit