Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
newtype Fizz = Fizz Int deriving (Show)
newtype Buzz = Buzz Int deriving (Show)
newtype Other = Other Int deriving (Show)
instance Arbitrary Fizz where
arbitrary = do
x <- (arbitrary `suchThat` (\n -> fizzBuzz n == "Fizz"))
return (Fizz x)
instance Arbitrary Buzz where
arbitrary = do
x <- (arbitrary `suchThat` (\n -> fizzBuzz n == "Buzz"))
return (Buzz x)
instance Arbitrary Other where
arbitrary = do
x <- (arbitrary `suchThat` (\n -> fizzBuzz n == (show n) && n /= 0))
return (Other x)
prop_fizzBuzz :: Fizz -> Buzz -> Bool
prop_fizzBuzz (Fizz a) (Buzz b) = fizzBuzz (a * b) == "FizzBuzz"
prop_fizzFizz :: Fizz -> Fizz -> Bool
prop_fizzFizz (Fizz a) (Fizz b) = fizzBuzz (a * b) == "Fizz"
prop_buzzBuzz :: Buzz -> Buzz -> Bool
prop_buzzBuzz (Buzz a) (Buzz b) = fizzBuzz (a * b) == "Buzz"
prop_fizz :: Other -> Fizz -> Bool
prop_fizz (Other a) (Fizz b) = fizzBuzz (a * b) == "Fizz"
prop_buzz :: Other -> Buzz -> Bool
prop_buzz (Other a) (Buzz b) = fizzBuzz (a * b) == "Buzz"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.