
13 Jan
2008
13 Jan
'08
11:06 a.m.
Fernando Rodriguez writes:
car (x:_) = x car [] = [] ... and try to apply them to some list, such as
car [1,2,3]
I get this odd error: No instance for (Num [a]) arising from the literal `3' ...
The error is really a bit cryptic (who cares, Nums or whatever...) but the error is here. Your 'car' picks the first element, or the empty LIST. So, the first element of the argument also must be a list, not a number, otherwise the type-checker yells. Jerzy Karczmarczuk