1
在Haskell即時通訊新,即時通訊做我的任務,其對銀行系統,我是說我要註冊新帳號程序錯誤此錯誤:Prelude.read:沒有解析程序錯誤:Prelude.read:沒有解析
的代碼如下:
createAcc :: IO()
createAcc = do
new <- readFile "db.txt" --Database named db--
let new1 = length (func new)
putStrLn " Enter your Name : " --write your name--
name <- getLine
putStrLn " Enter Balance :" --enter minimum balance to deposit--
bal <- getLine
let bal1 = read bal :: Int
store <- readFile "db.txt" --entries comes in database--
let store1 = func store
let store2 = store1 ++ [(new1+1,name,bal1)]
writeFile "db.txt" (show store2)
func :: String -> [(Int,String,Int)]
func x = read x:: [(Int,String,Int)]
你不能在許多懶惰的'readFile'和'writeFile'調用中混合使用同一個文件。你需要明確地管理你的手柄,確保它們根據需要被打開和關閉。 –