我为 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