On Sun, Oct 16, 2011 at 10:35 AM, Edward Kmett <span dir="ltr">&lt;<a href="mailto:ekmett@gmail.com">ekmett@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On Sun, Oct 16, 2011 at 1:45 AM, Isaac Dupree <span dir="ltr">&lt;<a href="mailto:ml@isaac.cedarswampstudios.org" target="_blank">ml@isaac.cedarswampstudios.org</a>&gt;</span> wrote:<br></div><div class="gmail_quote">

<div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>As others observed, &quot;one&quot; is only useful for the &quot;bit&quot; method default, and might be meaningless for an &quot;instance () Bits&quot; (whereas the rest of the class makes sense for () as a zero-bit instance, albeit a use doesn&#39;t come to mind).  Or, similarly to (), a bit-vector which contains its length statically in its type: it would be simpler if length zero was just as valid as any other length.  And it would be a bit strange to define &#39;one&#39; as a value equal to &#39;zero&#39;.</div>



<br></blockquote></div><div><div style="font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)"><br>It isn&#39;t entirely meaningless it is just out of range. It is perfectly well defined for me to set the 200th bit of a 64 bit integer, it just doesn&#39;t do anything. ;) Similarly setting the 1 bit of () would result in (), since there are no bits to set.</div>

</div></div></blockquote><div><br></div><div>This is hard to implement in practice, as the behavior of assembly instructions for bit manipulation isn&#39;t always defined on out of range values and working around that problem in Haskell code will often involve a bad performance trade-off (i.e. adding a branch). We have this problem with shiftL/shiftR, which are terribly slow, leading to no-one using these functions in production quality code (I think I&#39;ve seen unsafeShiftL/R implemented in at least 3-4 of our most commonly used libraries).</div>

<div><br></div><div>I suggest we hurry slowly here. Do we understand what the meaning of the Bits class is? Lets make sure we don&#39;t make it harder for use for the majority use case of performing bitwise operations on machine sized quantities.</div>

<div><br></div><div>Cheers,</div><div>Johan</div><div><br></div><div><br></div></div>