Ticket #19 (new defect)
Opened 5 years ago
indentation of if..then..else in do block is broken
|Reported by:||anonymous||Owned by:||Baughn|
I was working through the Yet Another Haskell Tutorial, and I noticed that the haskell-mode indentation for one of their examples forces me into making a syntax error.
The code in question is seen on this page http://en.wikibooks.org/wiki/Haskell/YAHT/Language_basics (search for Guess.hs). I will reproduce it here, with its original indentation:
module Main where import IO import Random main = do hSetBuffering stdin LineBuffering num <- randomRIO (1::Int, 100) putStrLn "I'm thinking of a number between 1 and 100" doGuessing num doGuessing num = do putStrLn "Enter your guess:" guess <- getLine let guessNum = read guess if guessNum < num then do putStrLn "Too low!" doGuessing num else if guessNum > num then do putStrLn "Too high!" doGuessing num else do putStrLn "You Win!"
haskell-mode is of the opinion that the 'sole indentation' for the "then" following the "if" in doGuessing is aligned with the "if". However, this indentation results in a syntax error.