Commit 4cd55218 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari

base: Add default implementation for Data.Bits.bitSize

Fixes #12970 and will provide a reasonable migration path for the
eventual remove of this function.

Test Plan: Validate

Reviewers: ekmett, hvr

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #12970

Differential Revision: https://phabricator.haskell.org/D4857
parent d55035f5
......@@ -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 -}
......
......@@ -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`,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment