<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 26 April 2015 at 06:10, Alexey Vagarenko <span dir="ltr"><<a href="mailto:vagarenko@gmail.com" target="_blank">vagarenko@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Yes, but ghci shows an error if it can't print a value, except when the value is in IO monad. Compare:<div><div style="border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code><div><span style="color:#606">Prelude</span><span style="color:#660">></span><span style="color:#000"> id<br></span><span style="color:#080"><interactive></span><span style="color:#660">:</span><span style="color:#066">6</span><span style="color:#660">:</span><span style="color:#066">1</span><span style="color:#660">:</span><span style="color:#000"><br> </span><span style="color:#606">No</span><span style="color:#000"> instance </span><span style="color:#008">for</span><span style="color:#000"> </span><span style="color:#660">(</span><span style="color:#606">Show</span><span style="color:#000"> </span><span style="color:#660">(</span><span style="color:#000">a0 </span><span style="color:#660">-></span><span style="color:#000"> a0</span><span style="color:#660">))</span><span style="color:#000"><br> </span><span style="color:#660">(</span><span style="color:#000">maybe you haven</span><span style="color:#080">'t applied enough arguments to a function?)<span class=""><br> arising from a use of `print'</span></span><span class=""><span style="color:#000"><br> </span><span style="color:#606">In</span><span style="color:#000"> a stmt of an interactive </span><span style="color:#606">GHCi</span><span style="color:#000"> command</span><span style="color:#660">:</span><span style="color:#000"> </span><span style="color:#008">print</span><span style="color:#000"> it<br></span><font color="#000000"><span style="color:#606">Prelude</span><span style="color:#660">></span></font><span style="color:#000"><br></span></span></div></code></div><div><br></div></div><div>and</div><div><br></div><div><div style="border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code><div><div>Prelude> return id</div><div>Prelude></div></div></code></div><br></div></div></blockquote><div><br></div><div>This behavior is necessary. For example, if we used any function with result of type IO (), such as writeFile, we don't want an error as we are interested in the side-effects only.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br><br>воскресенье, 26 апреля 2015 г., 5:48:55 UTC+6 пользователь Sumit Sahrawat, Maths & Computing, IIT (BHU) написал:<blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div dir="ltr">If something can't be shown (converted to a string), then it can't be printed (as a string).</div></span><div><br><div class="gmail_quote"><span class="">On 25 April 2015 at 17:51, Daniel van den Eijkel <span dir="ltr"><<a rel="nofollow">dv...@gmx.net</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">I wrote a parser and it took me a while to realize why GHCi suddenly did<br>
not show any result nor an error message anymore.<br>
<br>
My parsing function has type (IO Expression), Expression is in class Show.<br>
<br>
After changing the parser to (IO Declaration), it did not show anything<br>
anymore, because Declaration was not in class Show.<br>
<br>
When I typed (parseFile "input.txt" >>= print), I got the error message<br>
and understood what was going on. But for I while I was really confused<br>
what's happening.<br>
<br>
Just wanted to share this.<br>
<br>
Best,<br>
Daniel<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
</span><a rel="nofollow">Haskel...@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="nofollow" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br><br clear="all"><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>Regards</div><div dir="ltr"><div><br></div><div>Sumit Sahrawat</div></div></div></div></div></div></div>
</font></span></div>
</blockquote></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>Regards</div><div dir="ltr"><div><br></div><div>Sumit Sahrawat</div></div></div></div></div></div></div>
</div></div>