From: David <ronoterile@ya...> - 2003-08-24 14:54:47
The function "textCtrlGetValue" returns a IO String. I need to modificate
this string. How can i use it as a string? I mean, how can i convert an "IO
a" to a simply "a"?
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
> The function "textCtrlGetValue" returns a IO String.
> I need to modificate this string. How can i use it
> as a string?
You should read about the concept of monadic IO in Haskell, since that will
probably answer your question. That will tell you about the do-construct
that you can use in this situation and its limits.
> I mean, how can i convert an "IO
> a" to a simply "a"?
There is a nasty function called "unsafePerformIO" that does just that, but
you should not use it in this case as it likely does not behave as you might
expect, since textCtrlGetValue depends on the environment (for example, the
state of the control).
---quote from GHC Haskell Libraries pdf---
unsafePerformIO :: IO a -> a
This is the "back door" into the IO monad, allowing IO computation to be
performed at any time. For this to be safe, the IO computation should be
free of side effects and independent of its environment.