type Record=([Char],[Char],[Char],[Char],[Char])
createAccount::IO()->Record
createAccount=do
putStrLn "Enter First Name"
fname<-getLine
putStrLn "Enter Last Name"
lname<-getLine
putStrLn "Enter State"
state<-getLine
putStrLn "Enter City"
city<-getLine
putStrLn "Enter House No."
hnum<-getLine
let hnumInt = read hnum :: Integer
putStrLn "Enter Contact"
contact<-getLine
return (fname,lname,state,city,contact)
Run Code Online (Sandbox Code Playgroud)
错误消息是说类型签名createAccount实际上是:
createAccount :: IO ([Char],[Char],[Char],[Char],[Char])
Run Code Online (Sandbox Code Playgroud)
不像IO() -> Record你宣布的那样.
修复它的选项:
IO ([Char],[Char],[Char],[Char],[Char])(或equivalenly: IO Record)