aboutsummaryrefslogtreecommitdiffstats
path: root/src/Test/VeriFuzz/Types.hs
blob: 0e6dea804e85f6e4bddb47ba6b293af674afced5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Test.VeriFuzz.Types where

import           System.Random
import           Test.QuickCheck

data Gate = And
          | Or
          | Xor
          | Nor
          | Nand
          deriving (Show, Eq, Enum, Bounded, Ord)

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]