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||Test Case:|
|Related Tickets:||Differential Rev(s):|
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.
Change History (8)
Changed 3 years ago by joeyadams
comment:2 Changed 3 years ago by pcapriotti
- difficulty set to Unknown
- Milestone set to 7.6.1
- Status changed from new to patch
- Version set to 7.7
comment:3 Changed 3 years ago by igloo
- Resolution set to wontfix
- Status changed from patch to closed
comment:5 Changed 3 years ago by jwlato
- Cc jwlato@… added
- Resolution wontfix deleted
- Status changed from closed to new