Re-export Data.Bits from GHC.Prelude with custom shift implementation.
The safe shifts can introduce branches which come at the cost of performance. We still want the additional debugability for debug builds. So we define it as one or the other depending on the DEBUG setting.
Why do we then continue on to re-export the rest of Data.Bits? If we would not what is likely to happen is:
- Someone imports Data.Bits, uses xor. Things are fine.
- They add a shift and get an ambigious definition error.
- The are puzzled for a bit.
- They either:
- Remove the import of Data.Bits and get an error because xor is not in scope.
- Add the hiding clause to the Data.Bits import for the shifts.
Either is quite annoying. Simply re-exporting all of Data.Bits avoids this making for a smoother developer experience. At the cost of having a few more names in scope at all time. But that seems like a fair tradeoff.
See also #19618 (closed)