Going back to an earlier question: a monad is a bit like a roach motel. You can check in but you can't leave. (This isn't true of every Monad, but the point is there's no guarantees.) In particular, you can't go from IO String to String _at all_. But you can, through Functor, pass it to a function that takes a plain S<span></span>tring. And through Monad, you can turn IO (IO String) back to IO String.<div><br></div><div>Hope this helps.<br><br>On Thursday, January 15, 2015, Marcin Mrotek <<a href="mailto:marcin.jan.mrotek@gmail.com">marcin.jan.mrotek@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
A list ([]) is also a monad, and a String is defined as a list of<br>
characters ([Char]). So in your example, it's as if you were trying to<br>
use (>>=) operator on two different monads ([] and IO), which is<br>
impossible. To make a pure value a monadic value, you need to use<br>
return:<br>
<br>
g = readLn >>= (\a -> return (f a))<br>
<br>
which is equivalent to composing f with return:<br>
<br>
g = readLn >>= return.f<br>
<br>
Regards,<br>
Marcin<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="javascript:;" onclick="_e(event, 'cvml', 'Beginners@haskell.org')">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br><br>-- <br>Sent from an iPhone, please excuse brevity and typos.<br>