haskell / haskell/core-libraries-committee
Remove bitSize from MINIMAL pragma of class Bits
- Dominant language
- Haskell
- Stars
- 109
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
[`bitSize`](https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Data-Bits.html#v:bitSize) is a member of [`class Bits`](https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Data-Bits.html#t:Bits), deprecated because of being partial in favor of total [`bitSizeMaybe`](https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Data-Bits.html#v:bitSizeMaybe) and [`finiteBitSize`](https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Data-Bits.html#v:finiteBitSize) back in [`base-4.7`](https://hackage-content.haskell.org/package/base-4.7.0.0/docs/Data-Bits.html#v:bitSize) (GHC 7.8, 2014).
Yet despite being deprecated `bitSize` remained a member of
```haskell
{-# MINIMAL (.&.), (.|.), xor, complement,
(shift | (shiftL, shiftR)),
(rotate | (rotateL, rotateR)),
bitSize, bitSizeMaybe, isSigned, testBit, bit, popCount #-}
```
which is very awkward: anyone defining `instance Bits Foo` has either define `bitSize` and receive a deprecation warning, or not define it and receive a warning about incomplete instance declaration.
Even when `bitSize` got a default implementation in [`base-4.12`](https://hackage-content.haskell.org/package/base-4.12.0.0/docs/src/Data.Bits.html#bitSize), it still remained a mandatory `{-# MINIMAL #-}` member of `class Bits`.
The proposal thus is to remove `bitSize` from `{-# MINIMAL #-}` of `class Bits`, allowing library authors finally to act on the deprecation warning and stop defining this function in their instances of `Bits`.
The proposal is meant to be a first step to a future removal of `bitSize` from `class Bits` as discussed in #440.
This proposal is not a breaking change.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the class Bits declaration and inspect the MINIMAL pragma shown in the issue, along with the default implementation of bitSize. Remove bitSize from the pragma while preserving the other requirements, then verify that the resulting declaration allows Bits instances to omit bitSize without an incomplete-instance warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100