how to convert IO String to string

Ashley Yakeley ashley@semantic.org
Fri, 22 Nov 2002 14:13:33 -0800


At 2002-11-22 08:12, Lu Mudong wrote:

>hi, all, I'm having problem convert IO String to string, I read a file, and 
>it's an IO String,

Right,

> what i need is a string,

You can do the conversion with "<-", but only inside a "do" block. For 
instance:

  myReadFile :: IO String
  myReadFile = ...

  main = do
    s <- myReadFile
    putStrLn s

Here, s has type String.


-- 
Ashley Yakeley, Seattle WA