Apparently, my type signature was off. I've since found out why. Now, I'm interested in knowing more about the GHCI inferred signature on my typo. I was trying to get this code to work:
elemNum :: (Eq a, Num b) => a -> [a] -> b
elemNum e l = f e l
where f _ [] = [] -- this was my typo, supposed to read 0
f e (x:xs)
| x == e = 1 + f e xs
| otherwise = f e xs
It obviously doesn't work for the reason noted above; but, if I remove my signature it compiles (not sure why, please explain), and I get this signature:
elemNum :: (Num [a], Eq t) => t -> [t] -> [a]
I've never seen the typeclass Num [a]
before.. What does that mean, and how does it compare to (Num a) => [a]
.