<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">Hi All,</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">As a newcomer to Haskell, I'm following a tutorial to learn I/O in Haskell.</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">As an exercise I'm writing a small code to read from an input text file and process it and then write it back to an output file. </div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">The problem is that, it doesn't write to the output file after the input is being processed.</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">Here's my code:</div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace"><br></font></div><div class="gmail_default" style><font face="monospace, monospace"><span style="font-size:small"> </span>module Main where</font></div><div class="gmail_default" style><font face="monospace, monospace"><br></font></div><div class="gmail_default" style><font face="monospace, monospace"> import System.IO</font></div><div class="gmail_default" style><font face="monospace, monospace"><br></font></div><div class="gmail_default" style><font face="monospace, monospace"> main = do</font></div><div class="gmail_default" style><font face="monospace, monospace"> input <- readFile "input.txt"</font></div><div class="gmail_default" style><font face="monospace, monospace"> let reversedInput = reverseInput (convert input)</font></div><div class="gmail_default" style><font face="monospace, monospace"> writeFile "reversed.txt" (reversedInput)</font></div><div class="gmail_default" style><font face="monospace, monospace"><br></font></div><div class="gmail_default" style><font face="monospace, monospace"> -- These two lines are not printed on the shell</font></div><div class="gmail_default" style><font face="monospace, monospace"> putStrLn (show reversedInput)</font></div><div class="gmail_default" style><font face="monospace, monospace"> putStrLn "Writing to file...."</font></div><div class="gmail_default" style><font face="monospace, monospace"><br></font></div><div class="gmail_default" style><font face="monospace, monospace"> -- Reversing the input</font></div><div class="gmail_default" style><font face="monospace, monospace"> reverseInput input = (last input) : reverseInput (init input)</font></div><div class="gmail_default" style><font face="monospace, monospace"> -- Convert from String IO -> String</font></div><div class="gmail_default" style><font face="monospace, monospace"> convert x = show (x)</font></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div><div><font face="georgia,serif">Regards, <br>Dananji Liyanage</font></div></div></div></div></div>
</div>