diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2018-11-09 20:34:24 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2018-11-09 20:34:24 +0000 |
commit | 8e4e3c6bfdb6a34650646cbc2330377771b74313 (patch) | |
tree | aad1688d76638dd2719543c809181e9c2148d8df /src/Test/VeriFuzz/Types.hs | |
parent | 34f044c3f91a747186c3ea7f700049278b40678d (diff) | |
download | verismith-8e4e3c6bfdb6a34650646cbc2330377771b74313.tar.gz verismith-8e4e3c6bfdb6a34650646cbc2330377771b74313.zip |
Random generation of DAG
Diffstat (limited to 'src/Test/VeriFuzz/Types.hs')
-rw-r--r-- | src/Test/VeriFuzz/Types.hs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/Test/VeriFuzz/Types.hs b/src/Test/VeriFuzz/Types.hs index 9c0de17..0528972 100644 --- a/src/Test/VeriFuzz/Types.hs +++ b/src/Test/VeriFuzz/Types.hs @@ -1,8 +1,21 @@ -module VeriFuzz.Types where +module Test.VeriFuzz.Types where + +import Test.QuickCheck +import System.Random data Gate = And | Or | Xor | Nor | Nand - deriving (Show, Eq, Ord) + deriving (Show, Eq, Enum, Bounded) + +instance Random Gate where + randomR (a, b) g = + case randomR (fromEnum a, fromEnum b) g of + (x, g') -> (toEnum x, g') + + random g = randomR (minBound, maxBound) g + +instance Arbitrary Gate where + arbitrary = elements [And, Or, Xor, Nor, Nand] |