我想在Haskell中編寫一個函數,它檢查一些事情,然後基於一些最小用戶輸入遞歸。爲了做到這一點,我認爲我必須使用do
塊。在Haskell中嵌套````塊
cip :: [Argument] -> [Argument] -> Bool -> Bool -> IO()
cip (a:args) pargs burden gameover = do
let nasko = a:pargs
putStrLn (getPremise a)
let newgraph = Carneades.mkArgGraph nasko
let newcaes = (CAES (newgraph,audience2,assStandarts))
let answer = (acceptable (mkProp (getPremise a)) newcaes)
print answer
if(answer==True)
then (cip args nasko burden gameover)
else do
print "One of the arguments is not proved. Here are the premises that need proving"
print (propsForFixing newcaes a)
print "Let's see what you have for the first Propositon"
--add an if to check if no applicable arguments.
print (argumentScanHelp (head (propsForFixing newcaes a)) args)
print "\n Would you like me to apply the firt one? Y/N"
choice <- getLine
if(choice=="Y") then do print "applying the argument"
let applicabee = head (argumentScanHelp (head (propsForFixing newcaes a)) args)
print "Argument targeted"
let newargs = delete applicabee args
let newpargs = applicabee:nasko
print "Argument applied sucsessfuly. Recusing again"
(cip newargs newpargs burden gameover)
return()
它傷害了我的眼睛只是看着它,但這是do
塊給你。 一切高達第三do
塊是好的。但隨後在這條線:
if(choice=="Y") then do print "applying the argument"
let applicabee = head (argumentScanHelp (head (propsForFixing newcaes a)) args)
的編譯器開始哭鬧:
Main.hs:209:73: parse error on input `let'
嘗試了各種不同的壓痕,但我似乎無法得到它的工作。 我不想使用單獨的函數,因爲這意味着我必須經常傳遞很多爭論。
任何人都可以幫助我解決問題嗎?另外一個解釋什麼是嵌套的do
塊的規格將不勝感激。
'if(answer == True)'與'if answer'相同 – amindfv