我是Haskell的新手,需要在这个情况下得到一些帮助。我有以下列表:
-- create a type for bank account
type AcNo = String
type Name = String
type City = String
type Amnt = Int
type AcInfo = [(AcNo, Name, City, Amnt)]
-- function to get the data of bank accounts to a list of tuples
bankAccounts :: AcInfo
bankAccounts = [("oo1", "Sahan", "Colomb", 100),("002", "John", "Jafna", 200)]
我的要求是根据账号获取对应的金额,例如,对于001账号,它应该返回100。
我编写的函数如下:
--Function to check the balance of a person
checkBalance :: bankAccounts -> AcNo -> Amnt
checkBalance dbase number = Amnt|(AcNo, Name, City, Amnt) <- dbase, AcNo==number}
我卡在第二行,出现了错误信息
输入语法错误(意外的“|”)
我需要一些帮助。谢谢。