I'm trying to do the exercises in Real World Haskell in a TDD fashion, using HUnit. As you probably guessed I haven't gotten far yet so I'm an absolute beginner when it comes to Haskell. Given the following code how can I resolve the following error ghci produces:
Ambiguous type variable
a' in the constraints:
Show a' arising from a use ofassertEqual' at List_Test.hs:6:27-58
Eq a' arising from a use of `assertEqual' at List_Test.hs:6:27-58 Probable fix: add a type signature that fixes these type variable(s)
List_Test.hs:
module List_Test
where
import List
import Test.HUnit
fromEmptyList = TestCase $ assertEqual "" [] (toList (Nil))
main = runTestTT fromEmptyList
List.hs:
module List
where
data List a = Cons a (List a)
| Nil
deriving (Show)
toList Nil = []
toList (Cons a b) = (:) a (toList b)
I've tried adding type constraints to both the List declaration and the toList definition without success. A internet search did also not provide any information.