How is that not a bug? We should be able to read back floats <span></span><br><br>On Monday, October 10, 2016, David Feuer <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">It doesn't, and it never has.</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Oct 10, 2016 6:08 PM, "Carter Schonwald" <<a href="javascript:_e(%7B%7D,'cvml','carter.schonwald@gmail.com');" target="_blank">carter.schonwald@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Read should accept exactly the valid source literals for a type. <span></span><br><br>On Monday, October 10, 2016, David Feuer <<a href="javascript:_e(%7B%7D,'cvml','david.feuer@gmail.com');" target="_blank">david.feuer@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">What does any of that have to do with the Read instances?</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Oct 10, 2016 1:56 PM, "Carter Schonwald" <<a>carter.schonwald@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The right solution is to fix things so we have scientific notation literal rep available. Any other contortions run into challenges in repsentavility of things. That's of course ignoring denormalized floats, infinities, negative zero and perhaps nans. <div><br></div><div>At the very least we need to efficiently and safely support everything but nan. And I have some ideas for that I hope to share soon. <span></span><br><br>On Monday, October 10, 2016, David Feuer <<a>david.feuer@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">I fully expect this to be somewhat tricky, yes. But some aspects of the current implementation strike me as pretty clearly non-optimal. What I meant about going through Rational is that given "625e-5", say, it calculates 625%100000, producing a fraction in lowest terms, before calling fromRational, which itself invokes fromRat'', a division function optimized for a special case that doesn't seem too relevant in this context. I could be mistaken, but I imagine even reducing to lowest terms is useless here. The separate treatment of the digits preceding and following the decimal point doesn't do anything obviously useful either. If we (effectively) normalize in decimal to an integral mantissa, for example, then we can convert the whole mantissa to an Integer at once; this will balance the merge tree better than converting the two pieces separately and combining.</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Oct 10, 2016 6:00 AM, "Yitzchak Gale" <<a>gale@sefer.org</a>> wrote:<br type="attribution"><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The way I understood it, it's because the type of "floating point" literals is<br>
<br>
Fractional a => a<br>
<br>
so the literal parser has no choice but to go via Rational. Once you<br>
have that, you use the same parser for those Read instances to ensure<br>
that the result is identical to what you would get if you parse it as<br>
a literal in every case.<br>
<br>
You could replace the Read parsers for Float and Double with much more<br>
efficient ones. But you would need to provide some other guarantee of<br>
consistency with literals. That would be more difficult to achieve<br>
than one might think - floating point is deceivingly tricky. There are<br>
already several good parsers in the libraries, but I believe all of<br>
them can provide different results than literals in some cases.<br>
<br>
YItz<br>
<div><br>
On Sat, Oct 8, 2016 at 10:27 PM, David Feuer <<a>david.feuer@gmail.com</a>> wrote:<br>
> The current Read instances for Float and Double look pretty iffy from an<br>
> efficiency standpoint. Going through Rational is exceedingly weird: we have<br>
> absolutely nothing to gain by dividing out the GCD, as far as I can tell.<br>
> Then, in doing so, we read the digits of the integral part to form an<br>
> Integer. This looks like a detour, and particularly bad when it has many<br>
> digits. Wouldn't it be better to normalize the decimal representation first<br>
> in some fashion (e.g., to 0.xxxxxxexxx) and go from there? Probably less<br>
> importantly, is there some way to avoid converting the mantissa to an<br>
> Integer at all? The low digits may not end up making any difference<br>
> whatsoever.<br>
><br>
><br>
</div>> ______________________________<wbr>_________________<br>
> ghc-devs mailing list<br>
> <a>ghc-devs@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/ghc-devs</a><br>
><br>
</blockquote></div><br></div>
</blockquote></div>
</blockquote></div></div>
</blockquote>
</blockquote></div></div>
</blockquote>