<div dir="ltr"><div class="gmail_quote"><div dir="ltr">Michael Orlitzky <<a href="mailto:michael@orlitzky.com">michael@orlitzky.com</a>> schrieb am Mo., 15. Aug. 2016 um 14:48 Uhr:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 08/14/2016 06:54 PM, David Feuer wrote:<br>
> Since decimal notation is defined in terms of fromRational, it seems a<br>
> bit strange that the notation doesn't work for read::String->Rational.<br>
> I'd be in favor of allowing it. I wouldn't expect too severe a<br>
> performance penalty.<br>
><br>
<br>
One potential gotcha:<br>
<br>
  ghci> read (show (1/3)) == (1/3)<br>
  True<br>
  ghci> read (show (1/3 :: Float)) == (1/3)<br>
  False<br>
<br>
When does it work? Is it platform-dependent?<br></blockquote><div><br></div><div>Well, you are showing 1/3 as a Float and reading it as a Double, which of course won't work since the String represents a Float and not a Double. The following does work:</div><div><br></div><div>λ: read (show (1/3 :: Float)) == ((1/3) :: Float)</div><div>True</div><div><br></div></div></div>