我正在尝试为ADT写一些quickcheck属性:
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Test.QuickCheck
import Test.Framework.Providers.QuickCheck2
import Test.Framework.TH
import Test.Framework
-- Stub implementations, not relevant to this problem
encode x = x
decode x = x
data Activity = Run | Walk
instance Arbitrary Activity where
arbitrary = elements [Run, Walk]
prop_activity_can_be_serialized :: Activity -> Bool
prop_activity_can_be_serialized x = (decode . encode) x == x
main :: IO ()
main = defaultMain [$testGroupGenerator]
这不编译:
Test.hs:23:25:
No instance for (QuickCheck-2.5.1.1:Test.QuickCheck.Arbitrary.Arbitrary
Activity)
arising from a use of `testProperty'
Possible fix:
add an instance declaration for
(QuickCheck-2.5.1.1:Test.QuickCheck.Arbitrary.Arbitrary Activity)
In the expression: testProperty (Test.Framework.TH.fixName n)
In the expression:
\ n -> testProperty (Test.Framework.TH.fixName n)
In the expression:
\ n -> testProperty (Test.Framework.TH.fixName n)
"prop_activity_can_be_serialized" prop_activity_can_be_serialized
...但我确实为Arbitrary Activity
添加了一个实例声明。我错过了什么?