Removing bitSize

David Feuer david.feuer at gmail.com
Tue Jul 11 03:50:40 UTC 2017


The long-deprecated bitSize method of the Bits class is slated to be
removed in base-4.11 (GHC 8.4). There is one remaining question:
should we replace it with a *function* by that name with a FiniteBits
constraint? I don't feel very strongly either way, but Ryan Scott
seems in favor and Edward Kmett seems opposed. So it seems best to
bring it to the libraries list and let the CLC make the call. If the
function is added, it would look like this:

bitSize :: FiniteBits a => a -> Int
bitSize = finiteBitSize

The biggest downside I see is that we might one day want to reuse the
name for something with a better type, such as

bitSize :: forall proxy a. FiniteBits a => proxy a -> Int
bitSize _ = finiteBitSize (undefined :: a)

or

bitSize :: forall a. FiniteBits a => Tagged a Int
bitSize = Tagged (finiteBitSize (undefined :: a))

or (with type applications)

bitSize :: forall a. FiniteBits a => Int
bitSize = finiteBitSize (undefined :: a)

Thanks,
David Feuer


More information about the Libraries mailing list