我爲foldl寫了一個實現,並想檢查它是否工作,我嘗試了一些情況,它似乎運行良好,但我想確保。使用quickCheck
我也讀到了快速檢查,並嘗試過,但我似乎無法使它發揮作用,這是代碼
foldl'' :: (b -> a -> b) -> b -> [a] -> b
test :: Eq b => (b -> a -> b) -> b -> [a] -> Bool
test f e ls = foldl'' f e ls == foldl f e ls
當我運行quickCheck test
它引發以下錯誤:
No instance for (Show (b0 -> a0 -> b0))
arising from a use of `quickCheck'
Possible fix:
add an instance declaration for (Show (b0 -> a0 -> b0))
In the expression: quickCheck prueba
In an equation for `it': it = quickCheck prueba
不:類構造函數或類'盲」 – chamini2 2013-04-25 02:40:04
@ chamini2:你有沒有進口'Test.QuickCheck'? – hammar 2013-04-25 02:50:35
是的,也許是因爲我在OS X上?'ghci --version:The Glorious Glasgow Haskell Compilation System,version 7.4.2' – chamini2 2013-04-25 03:37:15