# Pastebin bkUnHAwg -- Defines a distinct type in the type system, which has the same -- runtime representation as Int. newtype ZeroToSix = ZeroToSix Int -- Give the ZeroToSix an Arbitrary instance so we can use it in -- QuickCheck properties. instance Arbitrary ZeroToSix where -- A generator of 'ZeroToSix's. arbitrary :: Gen ZeroToSix arbitrary = ZeroToSix <$> chooseInt 0 6 -- `shrink` helps QuickCheck find minimal counterexamples when a -- property is violated. shrink :: ZeroToSix -> [ZeroToSix] shrink (ZeroToSix n) = [ ZeroToSix x | x <- [0..(n-1)] ] qcProps = testGroup "(checked by QuickCheck)" [ QC.testProperty "add7 is commutative" $ \(ZeroToSix a) (ZeroToSix b) (ZeroToSix c) -> add7 a b c == add7 b c a ]