RFC: Default impl for bitSize in terms of bitSizeMaybe (was: bitSize/bitSizeMaybe)

Herbert Valerio Riedel hvr at gnu.org
Thu Sep 19 15:51:29 CEST 2013


On 2013-09-18 at 17:22:06 +0200, Edward Kmett wrote:
> I believe the resolution was to explicitly leave bitSizeMaybe _not_
> implemented in terms of bitSize to help ensure it gets filled in correctly.
>
> Im rather neutral on whether we should supply a definition in the other
> direction.

Me too... so we'd have something like

  bitSize :: a -> Int
  bitSize = fromJust . bitSizeMaybe

Then one benefit might be, that when you build-dep on the new base>=4.7,
you can start writing instances ignoring the deprecated `bitSize`
method, and just define `bitSizeMaybe`, and then the legacy `bitSize`
will be implicitly defined as well. When `bitSize` is finally removed,
your instance definition won't have to be adapted.

But I'm not sure if this convenience is enough to justify such a default
implementation.

Cheers,
  hvr



More information about the Libraries mailing list