コードを取得する場合:
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 "..."
):
addBook =
p >> getLine >>= (\tit ->
p >> getLine >>= (\aut ->
p >> getLine >>= (yr ->
(yr ->
あなたは意味をなさないことで終わっています。他に何もすることがない場合は、空のタプルを返すことができます:
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
ます。