
27 May
2007
27 May
'07
9 a.m.
junkywunky wrote:
type Person = (NI, Age, Balance) type Bank = [Person]
credit :: Bank -> [Person] credit [(a,b,c)] = [(a,b,c)]
This code works when I type in:
credit [(1,2,3)]
but doesn't work when I type in:
credit [(1,2,3),(4,5,6)]
Any help?
Thanks in advance.
The expression [(1,2,3),(4,5,6)] doesn't match the pattern [(a,b,c)]. Now, since Bank and [Person] are actually the exact same type and the credit function actually does nothing, you could simply write credit x = x (Or, for that matter, credit = id.) It would then work for both examples. I presume that the idea is that the credit function will eventually do something - in that case, it might be helpful to say exactly what you want it to actually do.