Problems with IO

?????? ????? ????? ?????? ????? ?????
Tue, 24 Sep 2002 16:59:07 +0400


My task is to write a parser for some language (TSG). I'm using an 
UU_Parsing library.
I wrote that parser even tested it by using some example provided, but I 
have problems with using my parser.
I wrote a function:

 > test :: [Char] -> IO ()
 > test inp = do     res <-  parseIO pTSG inp
 >       	    print res


parseIO :: InputState a b => AnaParser a Pair b c -> a b -> IO c
is provided by the library, pTSG is my parser and inp is a String that 
I'm parsing.

How can I use that function "test" while using readFile?

Is it something like:

 > test1 file = do  inp <- readFile file
 >                  test inp

Why should I use that "do" thing? What is so "magical" in it?

PS: Please, don't say that I'm stupid, I just have problem with 
understanding IO/Monad part, besides that is just me second week of 
Haskell... :)

PS1: "Haskell: The Craft of Functional Programming" didn't make that 
part clear to me. That's why I'm writing...

-- 
Pavel Zhbanov