We could go with bitDefault popCountDefault, testBitDefault to mirror the fmapDefault and foldMapDefault in Data.Traversable, but I don't particularly care which color we paint this bikeshed.<div><br></div><div>-Edward<br>
<br><div class="gmail_quote">On Mon, Oct 17, 2011 at 1:29 PM, Bas van Dijk <span dir="ltr"><<a href="mailto:v.dijk.bas@gmail.com">v.dijk.bas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I agree.<br>
<br>
We should then also drop the default implementation of popCount.<br>
<br>
What about adding and exporting helper functions like Ian mentioned:<br>
<div class="im"><br>
numBit :: (Bits a, Num a) => Int -> a<br>
</div>numBit i = 1 `shiftL` i<br>
{-# INLINE numBit #-}<br>
<br>
numPopCount :: (Bits a, Num a) => a -> Int<br>
numPopCount = go 0<br>
<div class="im"> where<br>
go !c 0 = c<br>
go c w = go (c+1) (w .&. w - 1)<br>
<br>
</div>numTestBit :: (Bits a, Num a) => a -> Int -> Bool<br>
x `numTestBit` i = (x .&. bit i) /= 0<br>
{-# INLINE numTestBit #-}<br>
<br>
Not sure about the names though?<br>
<div><div></div><div class="h5"><br>
On 17 October 2011 19:12, Edward Kmett <<a href="mailto:ekmett@gmail.com">ekmett@gmail.com</a>> wrote:<br>
> I have to admit this seems to be the most sensible solution, and avoids<br>
> stealing names that are more appropriate for numeric instances anyways.<br>
> -Edward<br>
><br>
> On Mon, Oct 17, 2011 at 3:26 AM, Joachim Breitner <<a href="mailto:mail@joachim-breitner.de">mail@joachim-breitner.de</a>><br>
> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> Am Samstag, den 15.10.2011, 17:41 -0700 schrieb John Meacham:<br>
>> > I would just remove the bit and testBit defalut instances, they seem<br>
>> > like reasonable primitives to be required for an instance.<br>
>><br>
>> I agree. Bits is certainly not something that a Haskell Beginner would<br>
>> have to implement every day, but is more likely a task that requires<br>
>> lots of thought and well-written code anyway. Having to implement these<br>
>> two functions as well is not a large burden there.<br>
>><br>
>> Greetings,<br>
>> Joachim<br>
>><br>
>> --<br>
>> Joachim "nomeata" Breitner<br>
>> <a href="mailto:mail@joachim-breitner.de">mail@joachim-breitner.de</a> | <a href="mailto:nomeata@debian.org">nomeata@debian.org</a> | GPG: 0x4743206C<br>
>> xmpp: <a href="mailto:nomeata@joachim-breitner.de">nomeata@joachim-breitner.de</a> | <a href="http://www.joachim-breitner.de/" target="_blank">http://www.joachim-breitner.de/</a><br>
>><br>
>><br>
>> _______________________________________________<br>
>> Libraries mailing list<br>
>> <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
>> <a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
>><br>
><br>
><br>
> _______________________________________________<br>
> Libraries mailing list<br>
> <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
><br>
><br>
</div></div></blockquote></div><br></div>