Hi All,
As a newcomer to Haskell, I'm following a tutorial to learn I/O in Haskell.
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.
The problem is that, it doesn't write to the output file after the input is being processed.
Here's my code:
module Main where
import System.IO
main = do
input <- readFile "input.txt"
let reversedInput = reverseInput (convert input)
writeFile "reversed.txt" (reversedInput)
-- These two lines are not printed on the shell
putStrLn (show reversedInput)
putStrLn "Writing to file...."
-- Reversing the input
reverseInput input = (last input) : reverseInput (init input)
-- Convert from String IO -> String
convert x = show (x)
--
Regards,
Dananji Liyanage