quickCheckResult只接受something -> Bool
,然後我模仿一些例子, 通如何從任意打印生成的結果?
[Colour] -> Bool
什麼是[顏色]的托架的功能?爲什麼不是Colour -> Bool
? 如何將任意實例傳遞給quickCheckResult?
data Colour = Green | Blue
instance Arbitrary Colour where
arbitrary = oneof [return Green, return Blue]
main = quickCheckResult ((\s -> s == s) :: [Colour] -> Bool)
[更新] 我的目標是以下可以運行
import Test.QuickCheck.Function
import Test.QuickCheck.Gen
import Test.QuickCheck
import Test.QuickCheck.Function
import Test.QuickCheck.Arbitrary
import Test.QuickCheck.Property
import Test.QuickCheck.Test
prop1 f g x = (g.f) x == (f.g) x where types = [f, g] :: [Int->Int]
instance CoArbitrary ex where
coarbitrary f g = prop1 (variant 0 f) (variant 0 g)
main = quickCheck prop1
test5.hs:11:10:
Illegal instance declaration for `CoArbitrary ex'
(All instance types must be of the form (T a1 ... an)
where a1 ... an are *distinct type variables*,
and each type variable appears at most once in the instance head.
Use -XFlexibleInstances if you want to disable this.)
In the instance declaration for `CoArbitrary ex'
3.How使用QuickCheck.Function(更新)
prop :: Fun Fun Integer -> Bool
let prop (Fun _ f) (Fun _ g) = (g.f) x == (f.g) x
quickCheck prop
解析錯誤(可能是不正確的縮進)
有人告訴我,第一批實施CoArbitrary如果要生成的功能,然後我發現CoArbitrary是任意 –
加回讓,也同樣的錯誤 –
只有在舊版本的快速檢查的。在較新的版本中,任意和任意的屬於不同的類型。您不需要同時實施任意和任意。其中只有一個就足夠了。 – nponeccop