how to convert IO String to string

Glynn Clements glynn.clements@virgin.net
Sun, 24 Nov 2002 20:53:15 +0000


Lu Mudong wrote:

> hi, all, I'm having problem convert IO String to string,

That's because you can't convert IO String to String.

> I read a file, and it's an IO String,

No.

Calling readFile doesn't read the file, and the value which readFile
returns isn't the result of reading the file. The value which readFile
returns is an "action" which represents the act of reading a file as a
String.

> what i need is a string, but couldn't figure out how to 
> do the convertion. there are couple posts talked about this topic, but 
> didn't work for me

Read the section of the Haskell tutorial regarding I/O:

	http://www.haskell.org/tutorial/io.html

I guarantee that you will not be able to figure out how I/O works in
Haskell by guessing. You need to actually read a tutorial on the
subject.

-- 
Glynn Clements <glynn.clements@virgin.net>