Proposal: Add hasBitSize to Data.Bits.Bits

Thomas Schilling nominolo at
Sun Jul 29 17:37:44 CEST 2012

On 29 July 2012 15:37, Thomas DuBuisson <thomas.dubuisson at> wrote:
>> Is 'bitSize' a useful function to use monomorphically? It seems a
>> waste and irritating to have it return Maybe if I'm not using
>> Integer.
> That is a great point.  Most my uses of 'bitSize' are monomorphic and
> Maybe would just be silly.  OTOH, I'd be more than happy to fix up any
> polymorphic code to include a new BitSize constraint.

To make sure I understand this correctly:

The current problem is that bitSize is a partial function *depending
on the type* of its argument (currently it always returns _|_ for
Integer, and is total for any other type). That does indeed seem like
a Bad Idea.

You propose to:

  1. Remove "bitSize" from the Bits class.
  2. Add a new class BitSize which only contains the "bitSize" method.
Integer would not be an instance of this class.

So, then:

  - I assume we want a deprecation cycle.  How, will that work?
  - Do we have a formal definition of what bitSize means? E.g.,
could/should a (finite) ByteString be made an instance of this?

/ Thomas

More information about the Libraries mailing list