嘿 - 伟大的编码员和 Haskell,我是一名 Haskell 新生,并且对程序有问题,它归结为以下情况
main :: IO ()
main = do
putStrLn "\nplease give me some input"
input1 <- getLine
putStrLn "\nplease give me another input"
input2 <-getLine
putStrLn ("\nyour inputs were "++show(input1)++" and "++ show(input2)")
putStrLn "restart ?? yY or nN"
c <- getChar
restart c
where
restart c
|elem c "yY" = do
main
|elem c "nN" = putStrLn "\nExample Over"
|otherwise = do
putStrLn "\nyou must type one of Yy to confirm or nN to abort"
c'<- getChar
restart c'
除了第一次执行 main
input1 <- getLine
被跳过,我找不到原因,如下
input2 <- getLine
按预期执行,我愿意接受任何建议和帮助,提前感谢 ε/2