I can't figure out how to annotate the mylast3 test properly:
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
I'm getting the following error pointing at the line "TestCase $ assertEqual "mylast3":
No instance for (Show a0) arising from a use of assertEqual The type variable a0 is ambiguous