<div dir="ltr"><div><div><div>many thanks,....but then I unfortunately don't understand how can I fix my initial problem:<br><br></div>to use IO check in guards - is that possible?<br><br></div>Regards,<br></div>Miro<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 15, 2015 at 10:12 PM, Julian Birch <span dir="ltr"><<a href="mailto:julian.birch@gmail.com" target="_blank">julian.birch@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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.<div><div class="h5"><br><br>On Thursday, January 15, 2015, Marcin Mrotek <<a href="mailto:marcin.jan.mrotek@gmail.com" target="_blank">marcin.jan.mrotek@gmail.com</a>> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">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></div></div><span class="">
_______________________________________________<br>
Beginners mailing list<br>
<a>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>
</span></blockquote></div><br><div class="HOEnZb"><div class="h5"><br>-- <br>Sent from an iPhone, please excuse brevity and typos.<br>
</div></div></blockquote></div><br></div>