From 86bc5c8596085d308df5d2c6ae5522bfb0ba50e0 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 15 Dec 2018 20:17:54 +0000 Subject: Rename types to circuit --- src/Test/VeriFuzz/Circuit.hs | 36 ++++++++++++++++++++++++++++++++++++ src/Test/VeriFuzz/Types.hs | 22 ---------------------- 2 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 src/Test/VeriFuzz/Circuit.hs delete mode 100644 src/Test/VeriFuzz/Types.hs (limited to 'src/Test/VeriFuzz') diff --git a/src/Test/VeriFuzz/Circuit.hs b/src/Test/VeriFuzz/Circuit.hs new file mode 100644 index 0000000..d934a3d --- /dev/null +++ b/src/Test/VeriFuzz/Circuit.hs @@ -0,0 +1,36 @@ +{-| +Module : Test.VeriFuzz.Circuit +Description : Definition of the circuit graph. +Copyright : (c) Yann Herklotz Grave 2018 +License : GPL-3 +Maintainer : ymherklotz@gmail.com +Stability : experimental +Portability : POSIX + +Definition of the circuit graph. +-} + +module Test.VeriFuzz.Circuit where + +import Data.Graph.Inductive +import System.Random +import Test.QuickCheck + +-- | The types for all the gates. +data Gate = And + | Or + | Xor + deriving (Show, Eq, Enum, Bounded, Ord) + +-- | Newtype for the Circuit which implements a Graph from fgl. +newtype Circuit = Circuit { getCircuit :: Gr Gate () } + +instance Random Gate where + randomR (a, b) g = + case randomR (fromEnum a, fromEnum b) g of + (x, g') -> (toEnum x, g') + + random = randomR (minBound, maxBound) + +instance Arbitrary Gate where + arbitrary = elements [And, Or, Xor] diff --git a/src/Test/VeriFuzz/Types.hs b/src/Test/VeriFuzz/Types.hs deleted file mode 100644 index 78fde7d..0000000 --- a/src/Test/VeriFuzz/Types.hs +++ /dev/null @@ -1,22 +0,0 @@ -module Test.VeriFuzz.Types where - -import Data.Graph.Inductive -import System.Random -import Test.QuickCheck - -data Gate = And - | Or - | Xor - deriving (Show, Eq, Enum, Bounded, Ord) - -newtype Circuit = Circuit { getCircuit :: Gr Gate () } - -instance Random Gate where - randomR (a, b) g = - case randomR (fromEnum a, fromEnum b) g of - (x, g') -> (toEnum x, g') - - random = randomR (minBound, maxBound) - -instance Arbitrary Gate where - arbitrary = elements [And, Or, Xor] -- cgit