我不知道如何正确注释 mylast3 测试:
import Test.HUnit
mylast :: [a] -> Maybe a
mylast [] = Nothing
mylast [x] = Just x
mylast (_:xs) = mylast xs
testsMyLast =
[TestCase $ assertEqual "mylast1" (Just 1) $ mylast [1],
TestCase $ assertEqual "mylast2" (Just 'b') $ mylast "ab",
TestCase $ assertEqual "mylast3" Nothing $ mylast [] <== how to test this correctly?
]
main = do runTestTT $ TestList testsMyLast
我收到以下错误指向“TestCase $ assertEqual”mylast3”行:
没有使用 assertEqual 产生 (Show a0) 的实例 类型变量 a0 不明确