Ticket #7135 (closed feature request: wontfix)
Data.Bits can still have default implementations for testBit, bit, and popCount by using -XDefaultSignatures
|Reported by:||joeyadams||Owned by:|
|Type of failure:||None/Unknown||Difficulty:||Unknown|
|Test Case:||Blocked By:|
In commit f99cee0 of the base package, the Num constraint was removed from the Bits class. Because the default implementations of testBit, bit, and popCount required Num, the same commit made them external functions instead.
We can still have default implementations for these if we use the -XDefaultSignatures GHC extension:
#ifdef __GLASGOW_HASKELL__ default bit :: Num a => Int -> a bit = bitDefault default testBit :: Num a => a -> Int -> Bool testBit = testBitDefault default popCount :: Num a => a -> Int popCount = popCountDefault #endif
Whether we want to do this or not, I'm not sure.
- This is more convenient.
- This may prevent people from encountering runtime errors in existing code that does not have bit, testBit, and popCount implementations, where the author forgot to compile with -Wall .
- Users get away with writing less portable code, so those who do wish to use non-GHC will have more support work to do.
The attached patch adds defaults for testBit, bit, and popCount, for GHC only. It does not update the documentation, though, so "Minimal complete definition" as-is would be misleading.
P.S.: This ticket is for GHC 7.6.1-rc1. That version tag is not available, though.