我想用haskell製作一個非常簡單的twitter客戶端,並且使事情變得簡單我正在嘗試做一個簡單的putStrLn和getLine(我不知道這是否是最好的解決方案對於這個問題或不是,我對haskell相當陌生)。小嘰嘰喳喳客戶端的Haskell IO cli菜單
我想要做這樣的事情,但輸出類型是不同的,所以它要給一個巨大的錯誤:
main:: IO()
main = do
putStrLn "1)Tweet\n 2)Timeline\n 3)DM\n 4)Inbox\n"
numero <- getLine
if(numero == 1)
then do
frase <- getLine
tweet frase
else
if(numero == 2)
then do
frase <- getLine
timeline frase
else
if(numero == 3)
then do
frase <- getLine
nome <- getLine
dm frase nome
else
if(numero == 4)
then
inbox
else do
PutstrLn "Invalido"
tweet :: String -> IO (Either String Tweet)
timeline :: String -> IO (Either String [Tweet])
dm :: String -> String -> IO(Either String DM)
inbox :: IO(Either String [DM])
就像我它去上面解釋給你喜歡的錯誤:
Main.hs:86:25: error:
Couldn't match type ‘Either String DM’ with ‘()’
Expected type: IO()
Actual type: IO (Either String DM)
和:
Main.hs:75:11: error:
• Couldn't match type ‘Either String Tweet’ with ‘()’
Expected type: IO()
Actual type: IO (Either String Tweet)
如果有人有意識解決這個特定的公關它會非常感激。
請發佈所有相關的代碼和錯誤消息。如果您的文章沒有提供[最小,完整和可驗證示例](http://stackoverflow.com/help/mcve),那麼很難爲您提供幫助。 – Mephy
@Mephy添加了一些示例 –
問題中存在拼寫錯誤。 'PutstLn'應該是'putStrLn'。 – Cirdec