【发布时间】:2013-10-07 14:07:11
【问题描述】:
type NI = Int
type Age = Int
type Balance = Int
type Person = (NI, Age, Balance)
type Bank = [Person]
sumAllAccounts :: NI -> Bank -> Int
sumAllAccounts n l = filter niMatch l
where niMatch n (a,_,_)
| n == a = True
| otherwise = False
当我运行这个函数时,我得到一个类型错误
couldnt match type (Person, t0, t1) -> Bool with Bool
但是,当我让 where 成为它自己的功能时,它可以工作
personNIMatchs :: NI -> Person -> Bool
personNIMatchs n (a,_,_)
| n == a = True
| otherwise = False
【问题讨论】:
-
请包含
Bank的定义。