Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created December 31, 2016 15:27
Show Gist options
  • Save deque-blog/868b78ec7a5272259e20c84eecdc7ade to your computer and use it in GitHub Desktop.
Save deque-blog/868b78ec7a5272259e20c84eecdc7ade to your computer and use it in GitHub Desktop.
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