Proposal: Remove Num superclass of Bits

Gábor Lehel illissius at gmail.com
Sat Oct 15 12:42:41 CEST 2011


On Sat, Oct 15, 2011 at 12:11 PM, Ian Lynagh <igloo at earth.li> wrote:
> On Sat, Oct 15, 2011 at 11:56:27AM +0200, Bas van Dijk wrote:
>> On 15 October 2011 00:01, Ian Lynagh <igloo at earth.li> wrote:
>> > Removing the Num superclass of Bits was also mentioned, but that would
>> > need its own proposal.
>>
>> Ok, I would like to propose removing the Num superclass of Bits.
>
> Would we just remove default methods like
>    bit i = 1 `shiftL` i
>    x `testBit` i = (x .&. bit i) /= 0
> ?

You could use DefaultSignatures[1]:

class Bits a where
    default bit :: Num a => Int -> a
    bit i = 1 `shiftL` i
    ...

Does it have to be/stay portable to non-GHC (or older GHC) compilers?

[1] http://www.haskell.org/ghc/docs/7.2.1/html/users_guide/type-class-extensions.html#class-default-signatures

>
>
> Thanks
> Ian
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>



-- 
Work is punishment for failing to procrastinate effectively.



More information about the Libraries mailing list