
Generally every function that uses something in the IO monad *has* to
return something in the IO monad or a monad transformer that has IO at
its base.
This is so that you can track any function that could potentially have
some side-effect just by looking at the signature.
There is a function called "unsafePerformIO" which subverts this by
turning an 'IO a' into an 'a', but it's not really meant for general
use.
This frustrated me in the beginning too, but I found that if I was
using 'unsafePerformIO' too much the design was probably bad.
-deech
On Thu, May 5, 2011 at 5:48 PM,
Hi,
I have a silly question, Can i get things out of IO monad?
for example, function 'anotherFun' doesn't work.
genFunc :: IO String
anotherFunc :: (Monad m) => m String -- m is a complex monad and is not an IO monad -- m is not an instance of MonadIO so liftIO will not work anotherFunc = do genStr <- genFunc return genStr
I just want to get something from IO monad and wrap it with some other monad. Is there anyway to do that? Thanks. _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners