我有两个函数foo
必须满足的属性:
prop_1 :: [Int] -> Bool
prop_1 xs = foo xs id == xs
prop_2 :: [Int] -> (Int -> Int) -> (Int -> Int) -> Bool
prop_2 xs f g = foo (foo xs f) g == foo xs (g . f)
我正在尝试使用 quickCheck 检查上述属性是否满足以下功能:
foo :: [a] -> (a -> b) -> [b]
foo xs f = []
当我尝试使用 prop_2 运行 quickCheck 时,出现以下错误:
quickCheck(prop_2)
<interactive>:18:1: error:
No instance for (Show (Int -> Int))
arising from a use of 'quickCheck'
(maybe you haven't applied a function to enough arguments?)
In the expression: quickCheck (prop_2)
In an equation for 'it': it = quickCheck (prop_2)
我不确定为什么会收到此错误以及如何解决它。任何见解都值得赞赏。