我是 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}
第二行是我卡在它给出错误消息的地方
输入中的语法错误(意外的“|”)
我想在这方面得到一些帮助。谢谢。