Bit shifting limitations

John Meacham john at repetae.net
Sun Jul 13 21:34:46 UTC 2014


On Sun, Jul 13, 2014 at 2:23 PM, David Feuer <david.feuer at gmail.com> wrote:
> Well, bitSize is deprecated in favor of two safe alternatives, including
> finiteBitSize. It is unfortunate that the signed stuff in my default creates
> a Num dependency--that may be enough to kill it. The case of Integer is
> pretty peculiar. What do people use that instance for?

Infinite bit sets I guess, I don't think it is that unreasonable to
exist, were it not for that pesky bitSize.

FiniteBits and that deprecation are GHC specific. Though, it would
make sense to port to jhc, it's fairly annoying for portable code to
rely on ad-hoc changes like this.

Looks like some work went into removing the Num superclass in ghc's
base. Hmm... I think type class aliases are needed to actually make it
backwards compatible though. Since bit is a primitive, you can get
zero from the somewhat awkward 'clearBit 0 (bit 0)' and one from 'bit
1' and -1 from complement zero so the defaults that were dropped can
be added back in using those.

    John
-- 
John Meacham - http://notanumber.net/


More information about the Libraries mailing list