Thanks a lot for you guys' help. I am very new to haskell and tried some methods you guys advised, doesn't seem to work, i think i didn't do it properly, here's my code and result, hope you can point out what's wrong. thanks! my code: myReadFile :: IO String myReadFile = readFile "d:/hugs98/input.txt" theString :: String theString = do s <- myReadFile putStrLn s the error message i got in hugs98 ERROR "D:\hugs98\parser.hs":16 - Type error in explicitly typed binding *** Term : theString *** Type : IO () *** Does not match : String
From: Ashley Yakeley <ashley@semantic.org> To: "Ahn Ki-yung" <kyagrd@bawi.org>,"Haskell List" <haskell@haskell.org> Subject: Re: how to convert IO String to string Date: Fri, 22 Nov 2002 15:09:34 -0800
At 2002-11-22 14:49, Ahn Ki-yung wrote:
'do' is a syntactic sugar of monadic operations. The original form can be written as
main = myReadFile >>= \s -> putStrLn s
That's correct. In this case, the 's' has type String. So the IO String has been 'converted' into a String, but only within the context of the IO monad.
I think ultimately everything is syntactic sugar.
-- Ashley Yakeley, Seattle WA
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
_________________________________________________________________ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail