I totally agree with you.  Haskell is very broken when it comes to [x..y] for floating point.<div>It&#39;s an attempt to make it more &quot;friendly&quot; for naive users, but there is no way FP can be made friendly.  Any such attempts will fail, so make it usable for people who understand FP instead.</div>
<div><br></div><div>  -- Lennart<br><br><div class="gmail_quote">On Mon, Sep 26, 2011 at 10:02 AM, Richard O&#39;Keefe <span dir="ltr">&lt;<a href="mailto:ok@cs.otago.ac.nz">ok@cs.otago.ac.nz</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
On 23/09/2011, at 4:06 PM, Chris Smith wrote:<br>
<br>
&gt; On Fri, 2011-09-23 at 11:02 +1200, Richard O&#39;Keefe wrote:<br>
&gt;&gt; I do think that &#39;..&#39; syntax for Float and Double could be useful,<br>
&gt;&gt; but the actual definition is such that, well, words fail me.<br>
&gt;&gt; [1.0..3.5] =&gt; [1.0,2.0,3.0,4.0] ????  Why did anyone ever think<br>
&gt;&gt; _that_ was a good idea?<br>
&gt;<br>
&gt; In case you meant that as a question, the reason is this:<br>
&gt;<br>
&gt;    Prelude&gt; [0.1, 0.2 .. 0.3]<br>
&gt;    [0.1,0.2,0.30000000000000004]<br>
<br>
</div>That shows why it is a *BAD* idea.<br>
0.3 comes out as 0.29999999999999998890<br>
so the final value is clearly and unambiguously<br>
*outside* the requested range.<br>
<div class="im"><br>
&gt; Because of rounding error, an implementation that meets your proposed<br>
&gt; law would have left out 0.3 from that sequence, when of course it was<br>
&gt; intended to be there.<br>
<br>
</div>But the output shown does NOT include 0.3 in the sequence.<br>
<br>
0.3 `elem` [0.1, 0.2 .. 0.3]<br>
<br>
is False.<br>
<div class="im"><br>
&gt;  This is messy for the properties you want to<br>
&gt; state, but it&#39;s almost surely the right thing to do in practice.<br>
<br>
</div>I flatly deny that.  I have access to several programming languages<br>
that offer &#39;REAL DO&#39;, including Fortran, R, and Smalltalk.  They all<br>
do the same thing; NONE of them overshoots the mark.<br>
<br>
If I *wanted* the range to be enlarged a little bit,<br>
I would enlarge it myself:  [0.1, 0.2 .. 0.3+0.001] perhaps.<br>
<div class="im"><br>
&gt;  If the<br>
&gt; list is longer, then the most likely way to get it right is to follow<br>
&gt; the behavior as currently specified.<br>
<br>
</div>I don&#39;t see the length of the list as having much relevance; if the<br>
bug shows up in a list of length 3, it is clearly not likely to be<br>
any better for longer lists.  This is NOT by any stretch of the<br>
imagination, it is a BUG.  If you have used REAL DO in almost any other<br>
programming language, you will be shocked and dismayed by its behaviour<br>
in Haskell.<br>
<br>
Programming constructs that are implemented to do what would probably<br>
meant if you were an idiot instead of what you *asked* for are<br>
dangerous.<br>
<div class="im"><br>
&gt; If you can clear this up with a better explanation of the properties,<br>
&gt; great!  But if you can&#39;t, then we ought to reject the kind of thinking<br>
&gt; that would remove useful behavior when it doesn&#39;t fit some theoretical<br>
&gt; properties that looked nice until you consider the edge cases.<br>
<br>
</div>I don&#39;t see any useful behaviour here.<br>
I see an implausibly motivated bug and while I _have_ written REAL DO<br>
in the past (because some languages offer only one numeric type), I<br>
cannot imagine wishing to do so in Haskell, thanks to this bug.  What<br>
I want now is a compiler option, on by default, to assure me that I am<br>
*not* using floating point numeration in Haskell.<br>
<div><div></div><div class="h5"><br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div>