Thank you so much, Luca. Mmm... I want to make a "List of Sentence" from some text file. inputFile.txt is like this. -------------------------------- This is a pen. Is this a pen? etc...many sentence. Each line, only one sentence. How can I make a list of sentence? How can I declared inpStr? Thank you. Sincerely, Sok Chang 2010/12/14 Luca Toscano <toscano.luca@gmail.com>
On 12/14/2010 07:24 AM, Sok H. Chang wrote:
Hello, everyone.
Hello, I don't understand very well what you're trying to do in your code, but if it is simply reading from a file and put the output into another file there is a better way:
import System.IO import System.Random
sentenceAry = []
main :: IO () main = do inh <- openFile "c:\\Documents and Settings\\shaegis\\inputFile.txt" ReadMode outh <- openFile "c:\\Documents and Settings\\shaegis\\outputFile.txt" WriteMode mainloop inh outh hClose inh hClose outh
mainloop :: Handle -> Handle -> IO () mainloop inh outh = do ineof <- hIsEOF inh if ineof then return () else do inpStr <- hGetLine inh hPutStrLn outh inpStr mainloop inh outh
I hope I've understood the problem.. In your code 'inpStr' wasn't in scope, because you've declared it only into else block..
Luca
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- Sok Ha, CHANG Open Mind Clinic/Academy, 1551-1, Sa-Dong, SangRok-Gu, AnSan-City, KyongGi-Do Tel: 031-407-6114 HP: openmind.ac / www.openmind.ac