如果你把你的代码:您与(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