0

I'm having some problems with parsing the code. I'm getting the following error message :

project.hs:82:17: error: parse error on input ‘<-’ Perhaps this statement should be within a 'do' block?

The code is the following :

firstLetters_main :: IO() 
firstLetters_main = do
    system "cls"
    putStr "Input file : "
    op1 <- getLine
    putStr "Output file : "
    op2 <- getLine
    let ans1 = read op1
    let ans2 = read op2
    istream <- readFile ans1
    ostream <- openFile ans2 WriteMode
    let str = lines istream
    hPutStrLn ostream (show (firstLetters str))

The error message points to the line :

ostream <- openFile ans2 WriteMode

This program is changing every sentences starting words first letter to upper case if it isn't already( firstLetters ) without changing the input files structure, in case it has more lines, and puts it in an output file.

Thanks in advance!

jikrthrttr
  • 11
  • 2
  • 2
    I can't see anything wrong in your code. Double check the indentation, and check if you have any tab characters in your source (there are none I can see in your post). I'd also recommend to turn on warnings with `-Wall`, sometimes it can reveal something important. – chi May 03 '17 at 20:13
  • I've double checked for tab characters, and it seems that there was one, right in front of that line, disguised and not seen by my editor. Thanks for the suggestion. Problem solved, case closed. Thank you, again! – jikrthrttr May 03 '17 at 20:27

0 Answers0