【发布时间】:2011-03-05 06:18:03
【问题描述】:
我想知道 IO() 函数能否返回元组,因为我想从这个函数中取出这些作为另一个函数的输入。
investinput :: IO()->([Char], Int)
investinput = do
putStrLn "Enter Username : "
username <- getLine
putStrLn "Enter Invest Amount : "
tempamount <- getLine
let amount = show tempamount
return (username, amount)
请帮忙。
谢谢。
【问题讨论】:
-
尝试删除类型签名,将
show更改为read,并在添加read的行末尾添加:: Int。然后在 GHCi 中加载它,试一试,并询问带有:t的类型。它不会是你在这里所拥有的。
标签: haskell io interactive