如果你把你的代碼:您與(yr ->
結束了
addBook =
p >> getLine >>= (\tit ->
p >> getLine >>= (\aut ->
p >> getLine >>= (yr ->
:
addBook = do
putStrLn "Enter the title of the Book"
tit <- getLine
putStrLn "Enter the author of "++tit
aut <- getLine
putStrLn "Enter the year "++tit++" was published"
yr <- getLine
和 「翻譯」 爲 「正常」(非do
)符號(給出p = putStrLn "..."
)這沒有意義。如果你沒有別的有用的事,你可以返回一個空的元組:
return()
末:
addBook = do
putStrLn "Enter the title of the Book"
tit <- getLine
putStrLn "Enter the author of "++tit
aut <- getLine
putStrLn "Enter the year "++tit++" was published"
yr <- getLine
return()
你或許應該問自己,爲什麼你需要得到aut
和yr
雖然。
這可能與其他人有關......我在「do」的第一行用製表符縮進,其餘用空格:P – 2012-05-25 05:14:02