diff options
| -rw-r--r-- | libraries/base/Data/Bits.hs | 4 | ||||
| -rw-r--r-- | libraries/base/changelog.md | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/libraries/base/Data/Bits.hs b/libraries/base/Data/Bits.hs index 60edf78dea..18110b55a8 100644 --- a/libraries/base/Data/Bits.hs +++ b/libraries/base/Data/Bits.hs @@ -190,8 +190,12 @@ class Eq a => Bits a where {-| Return the number of bits in the type of the argument. The actual value of the argument is ignored. The function 'bitSize' is undefined for types that do not have a fixed bitsize, like 'Integer'. + + Default implementation based upon 'bitSizeMaybe' provided since + 4.12.0.0. -} bitSize :: a -> Int + bitSize b = fromMaybe (error "bitSize is undefined") (bitSizeMaybe b) {-| Return 'True' if the argument is a signed type. The actual value of the argument is ignored -} diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index 5188fa9331..9e896d3671 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -325,6 +325,9 @@ * New `Control.Exception.TypeError` datatype, which is thrown when an expression fails to typecheck when run using `-fdefer-type-errors` (#10284) + * The `bitSize` method of `Data.Bits.Bits` now has a (partial!) + default implementation based on `bitSizeMaybe`. (#12970) + ### New instances * `Alt`, `Dual`, `First`, `Last`, `Product`, and `Sum` now have `Data`, |
