<br><br><div class="gmail_quote">On Thu, Apr 5, 2012 at 8:29 PM, damodar kulkarni <span dir="ltr"><<a href="mailto:kdamodar2000@gmail.com">kdamodar2000@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
See this:<br><span style="font-family:courier new,monospace">Prelude> :t 2.3</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">2.3 :: Fractional a => a</span><br style="font-family:courier new,monospace">
<br>Hope this helps.<div class="HOEnZb"><div class="h5"><br><br><br><div class="gmail_quote">On Thu, Apr 5, 2012 at 7:24 PM, <span dir="ltr"><<a href="mailto:j.romildo@gmail.com" target="_blank">j.romildo@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>On Thu, Apr 05, 2012 at 01:18:39PM +0000, Amy de Buitléir wrote:<br>
> <j.romildo <at> <a href="http://gmail.com" target="_blank">gmail.com</a>> writes:<br>
> > Why does (read "2" + 1) works, but (read "2.3" + 1) fail at runtime?<br>
><br>
> Try this:<br>
><br>
> read "2.3" + 1 :: Float<br>
><br>
> Or this:<br>
><br>
> read "2.3" + 1.0<br>
><br>
> The reason that your version didn't work is because GHCi is guessing that you<br>
> want the read operation to parse an Integer, since you're adding it to 1.<br>
<br>
</div>This is explanation does not seem to be enough once we consider the type<br>
of the literal 1:<br>
<br>
Prelude> :t 1<br>
1 :: Num a => a<br>
<br>
That is, the literal 1 is overloaded to any numeric type. It is not<br>
necessarily an Integer.<br>
<br>
Romildo<br>
<div><div><br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">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>
</div></div></blockquote></div><br><br clear="all"><br></div></div><span class="HOEnZb"><font color="#888888">-- <br>Thanks and regards,<br>-Damodar Kulkarni<br><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Thanks and regards,<br>-Damodar Kulkarni<br><br>