I don&#39;t mind the 0.0 == -0.0 case, its the NaN /= NaN one that gets me. ;)<div><br></div><div>The former just says that the equivalence relation you are using isn&#39;t structural. The latter breaks the notion that you have an equivalence relation by breaking reflexivity.<div>
<br></div><div>Eq doesn&#39;t state anywhere that the instances should be structural, though in general where possible it is a good idea, since you don&#39;t have to worry about whether or not functions respect your choice of setoid.</div>
<div><br></div><div>Ultimately, I find myself having to play a bit unsafe with lazy bytestrings more often than I&#39;d like to admit. Use of toChunks should always be careful to be safe to work regardless of the size of the chunks exposed, and can also rely on the extra-logical fact enforced by the bytestring internals that each such chunk is non-empty.</div>
<div><br></div><div>It greatly facilitates &#39;lifting&#39; algorithms that work over strict bytestrings to work over their lazy kin, and its omission would deal a terrible blow to the practical usability and efficiency of the bytestring library. I frankly would be forced to reimplement them from scratch in several packages were it gone.</div>
<div><br></div><div>Ultimately, almost any libraries relies on a contract that extends beyond the level of the type system to ensure they are used them correctly. A malformed &#39;Ord&#39; instance can wreak havoc with Set, a non-associative &#39;Monoid&#39; can leak structural information out of a FingerTree.</div>
<div><br></div><div>Similarly, the pleasant fiction that x == y ==&gt; f x == f y -- only holds if the Eq instance is structural, and toChunks can only &#39;safely&#39; be used in a manner that is oblivious to the structural partitioning of the lazy bytestring.</div>
<div><br></div><div>-Edward Kmett</div><div><div><br><div class="gmail_quote">On Mon, Apr 19, 2010 at 6:02 PM, Ashley Yakeley <span dir="ltr">&lt;<a href="mailto:ashley@semantic.org">ashley@semantic.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


  
  

<div>
Why is a function that gets a bunch of strict ByteStrings out of a lazy one exposed?<br>
<br>
In any case, it sounds like a similar situation to (==) on Float and Double. There&#39;s a mismatch between the &quot;Haskellish&quot; desire for a law on (==), and the &quot;convenient&quot; desire for -0.0 == 0.0, or for exposing toChunks. Which one you prefer depends on your attitude. My point is not so much to advocate for the Haskellish viewpoint than to recognise the tension in the design. Float and Double are pretty ugly anyway from a Haskell point of view, since they break a bunch of other desirable properties for (+), (-) and so on.<br>

<br>
The theoretical reason for using floating point rather than fixed point is when one needs relative precision over a range of scales: for other needs one should use fixed point or rationals. I added a Fixed type to base, but it doesn&#39;t implement the functions in the Floating class and I doubt it&#39;s as fast as Double for common arithmetic functions.<br>

<br>
It would be possible to represent the IEEE types in a Haskellish way, properly revealing all their ugliness. This would be gratifying for us purists, but would annoy those just trying to get some numeric calculations done.<br>

<br>
-- <br><font color="#888888">
Ashley Yakeley</font><div><div></div><div class="h5"><br>
<br>
<br>
On Mon, 2010-04-19 at 15:32 -0400, Edward Kmett wrote:<br>
<blockquote type="CITE">
    Because it is the most utilitarian way to get a bunch of strict ByteStrings out of a lazy one.<br>
    <br>
    Yes it exposes an implementation detail, but the alternatives involve an unnatural amount of copying.<br>
    <br>
    -Edward Kmett<br>
    <br>
</blockquote>
<blockquote type="CITE">
    On Sat, Apr 17, 2010 at 6:37 PM, Ashley Yakeley &lt;<a href="mailto:ashley@semantic.org" target="_blank">ashley@semantic.org</a>&gt; wrote:
</blockquote>
<blockquote type="CITE">
    <blockquote>
        Ketil Malde wrote:<br>
        <blockquote>
            Do we also want to modify equality for lazy bytestrings, where equality<br>
            is currently independent of chunk segmentation?  (I.e.<br>
            <br>
             toChunks s1 == toChunks s2 ==&gt; s1 == s2  <br>
            but not vice versa.)<br>
        </blockquote>
        <br>
        <br>
    </blockquote>
</blockquote>
<blockquote type="CITE">
    <blockquote>
        Why is toChunks exposed?<br>
        <br>
        -- <br>
        <font color="#888888">Ashley Yakeley</font>
    </blockquote>
</blockquote>
<blockquote type="CITE">
    <blockquote>
        <br>
    </blockquote>
</blockquote>
<blockquote type="CITE">
    <blockquote>
        <br>
        _______________________________________________<br>
        Haskell-Cafe mailing list<br>
        <a href="mailto:Haskell-Cafe@haskell.org" target="_blank">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>
        <br>
    </blockquote>
</blockquote>
<blockquote type="CITE">
    <br>
<pre>_______________________________________________
Haskell-Cafe mailing list
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a>
</pre>
</blockquote>
<br>
</div></div></div>

</blockquote></div><br></div></div></div>