
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

On Tue, May 12, 2015 at 10:47 AM, Dananji Liyanage

Thank you :)
On Tue, May 12, 2015 at 10:42 AM, Kim-Ee Yeoh
On Tue, May 12, 2015 at 10:47 AM, Dananji Liyanage
wrote: reverseInput input = (last input) : reverseInput (init input)
This won't terminate. That's the bug.
-- Kim-Ee
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-- Regards, Dananji Liyanage
participants (2)
-
Dananji Liyanage
-
Kim-Ee Yeoh