<br><br><div class="gmail_quote">On Fri, Jun 26, 2009 at 12:58 AM, Brandon S. Allbery KF8NH <span dir="ltr">&lt;<a href="mailto:allbery@ece.cmu.edu">allbery@ece.cmu.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div style=""><div><div class="im"><div>On Jun 26, 2009, at 00:43 , Hector Guilarte wrote:</div><blockquote type="cite"><div class="gmail_quote"><div>Thanks! Actually,  if I understood well what you proposed, that&#39;s how I first tought of doing it, but with a [Maybe String] and only append whenever I actually had a (Just string), but as I said before, I don&#39;t think my teacher is gonna like that solution since it is not going to print when the interpreter finds the show instruction in the GCL code, it is gonna wait until it finishes </div>

</div></blockquote><div><br></div></div><div>I think maybe you don&#39;t quite have a grasp of lazy evaluation yet.  Try it.</div><div class="im"><br><blockquote type="cite"><div class="gmail_quote"><div>Also, nobody has told me why I shouldn&#39;t just use my original solution using unsafePerformIO, is it really bad? is it dangerous? why is it &quot;unsafe&quot;?<br>

</div></div></blockquote><div><br></div></div>You were told earlier:</div><div><div class="im"><br><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div>Well, writing to the standard output is certainly a side effect. (This</div> does not mean that you cannot use unsafePerformIO. The compiler,<br> however, may assume that any value is free from side effects. This means<br>

 that you could get, in theory, less or more output from your program<br> than you want. In this sense it is not &quot;safe&quot;.)<br></blockquote></div></div></div></blockquote></div></blockquote></div></blockquote><div>

<br></div></div><div>Because pure (i.e. non-IO) values by definition never change, the compiler is free to assume that it can do them exactly once and remember the result.  This means that it is possible for the compiler to evaluate your unsafePerformIO once and never again... or, more likely, to notice that the pure result is always () (because unsafePerformIO &quot;hides&quot; the IO from the compiler) and optimize it away completely (the &quot;do it exactly once&quot; being at compile time instead of run time).</div>

</div></div></blockquote><div><br>Ok, I got it this time, thanks! I should really talk this with my teacher. I&#39;ll post whatever he tells me... Let&#39;s hope he lets me just acumulate all the strings and print them in the end.<br>

<br>Thanks again!<br><br>Hector Guilarte</div></div><br>