[Haskell-beginners] Is this scope range problem?

Sok H. Chang shaegis at gmail.com
Tue Dec 14 07:24:55 CET 2010


Hello, everyone.
Thank you so much to previous great answer!

Now, I don't know how can I fix this.

The error is,
Haskell>ghc --make Temp.hs -o Temp.exe
[1 of 1] Compiling Main             ( Temp.hs, Temp.o )

Temp.hs:19:27: Not in scope: `inpStr'

The code is,
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 do hPutStrLn outh inpStr
return ()
else do inpStr <- hGetLine inh
let sentenceAry = inpStr : []
mainloop inh outh



I'm try to change like below, but I failed.
mainloop :: Handle -> Handle -> IO ()
mainloop inh outh = do ineof <- hIsEOF inh
if not ineof
then do inpStr <- hGetLine inh
let sentenceAry = inpStr : []
mainloop inh outh
else do hPutStrLn outh inpStr
return ()


I wonder why...
Thank you.


Sincerely, Sok Chang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20101214/184b8acc/attachment.htm>


More information about the Beginners mailing list