2) No.
1) That is your syntax error. You should have "ranNoInt = <something>". The =<< operator is meant for the definition of the function.
Try this:
import System
import System.Random
main = readFile "C:\\Documents and Settings\\myHeader.txt" >>= myExtractSentence >>= putStrLn
myExtractSentence file = do
ranNoInt <- ranNo
return $ ary !! ranNoInt
where
ranNo = randomRIO (0, n-1)
n = length ary
ary = lines file
Hello, everyone.I need help for my first code.I write this code for extracting one sentence from text file.The code is-----------------------------------------------------------------------------------------------------------------------import Systemimport System.Randommain = do myHeader <- readFile "C:\\Documents and Settings\\myHeader.txt"putStrLn $ myExtractSentence myHeadermyExtractSentence file = ary !! ranNoIntwhereranNoInt =<< ranNo -- *markranNo = randomRIO (0, n-1)n = length aryary = lines file----------------------------------------------------------------------------------------------------------------------There are two questions.1) I've got following error message.Haskell>ghc --make Test01.hs -o Test[1 of 1] Compiling Main ( Test01.hs, Test01.o )Test01.hs:10:9: parse error (possibly incorrect indentation)How can fix it?2) Is it OK at "*mark" line?Thank you.S. CHANG
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners