Quickcheck2 - writing a modifier for test data

Hey, Using quickcheck2 I want to generate test data, that is a tuple of integers where both elements are >=0 and < 8. So I am trying to write a modifier (in the sense of the modifiers found in Modifiers.hs): newtype ValidPos = ValidPos Pos deriving Show instance Arbitrary ValidPos where arbitrary = do x <- elements [0..7] y <- elements [0..7] return (ValidPos (x,y)) prop_dummy (ValidPos pos) = fst pos > 0 tests = [ testGroup "Tests" [ testProperty "dummy" prop_dummy ] ] main = defaultMain tests doing so gives me this error: No instance for (QuickCheck-2.4.2:Test.QuickCheck.Arbitrary.Arbitrary ValidPos) arising from a use of `testProperty' Possible fix: add an instance declaration for (QuickCheck-2.4.2:Test.QuickCheck.Arbitrary.Arbitrary ValidPos) In the expression: testProperty "dummy" prop_dummy In the second argument of `testGroup', namely `[testProperty "dummy" prop_dummy]' In the expression: testGroup "Tests" [testProperty "dummy" prop_dummy] I declared the instance, why canit not be found? Thanks! Nathan

On Sun, Mar 31, 2013 at 12:21:48PM +0200, Nathan Hüsken wrote:
No instance for (QuickCheck-2.4.2:Test.QuickCheck.Arbitrary.Arbitrary ValidPos)
The fact that it actually lists the package and version number in the error message strongly suggests that the problem is conflicting versions of the QuickCheck package. Do 'ghc-pkg list QuickCheck' to see if you have multiple versions installed, and unregister all but one of them. -Brent

That was it. Thanks! On 03/31/2013 12:30 PM, Brent Yorgey wrote:
On Sun, Mar 31, 2013 at 12:21:48PM +0200, Nathan Hüsken wrote:
No instance for (QuickCheck-2.4.2:Test.QuickCheck.Arbitrary.Arbitrary ValidPos)
The fact that it actually lists the package and version number in the error message strongly suggests that the problem is conflicting versions of the QuickCheck package. Do 'ghc-pkg list QuickCheck' to see if you have multiple versions installed, and unregister all but one of them.
-Brent
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (2)
-
Brent Yorgey
-
Nathan Hüsken