私はこのコードを持っている:このdoブロックを元のモナドコードに変更するにはどうすればよいですか?
loop height weight=do
line<-getLine
if line=="1" then
do
height<-getLine
loop height weight
else if line=="2" then
do
weight<-getLine
loop height weight
else if line=="3" then
do
putStrLn (height)
else
do
putStrLn "error"
誰かが「やる」そんなにがある私に言った、私は「やる」を使用しないようにこのコードを変更しよう:
loop height weight=
getLine>>=(\line->(
if line=="1" then
getLine>>=(\height->
loop height weight
else if line=="2" then
getLine>>=(\weight->
loop height weight
else if line=="3" then
putStrLn (height+weight)
else
putStrLn "error"))))
をしかし、コンパイラは私に言いましたもし行== "2"で行が間違っていて、修正できない場合は
"do"を除いてこのコードを変更する方法を教えてください。
括弧のパリティを確認してください。 –