Proposal: Add hasBitSize to Data.Bits.Bits

Thomas DuBuisson thomas.dubuisson at gmail.com
Sun Jul 29 16:37:47 CEST 2012


On Sat, Jul 28, 2012 at 5:33 PM, Antoine Latter <aslatter at gmail.com> wrote:
> On Sat, Jul 28, 2012 at 11:57 AM, Andreas Abel <andreas.abel at ifi.lmu.de> wrote:
>> On 28.07.12 4:40 PM, John Lato wrote:
>>>>
>>>> From: Edward Kmett <ekmett at gmail.com>
>>>>
>>>> On Fri, Jul 27, 2012 at 3:42 PM, Ian Lynagh <igloo at earth.li> wrote:
>>>>
>>>>> On Fri, Jul 27, 2012 at 03:06:04PM -0400, Edward Kmett wrote:
>>>>>>
>>>>>> There is currently no way to know whether or not calling
>>>>>> Data.Bits.bitSizewill crash your program.
>>>>>>
>>>>>> I propose extending the Bits class to include:
>>>>>>
>>>>>> hasBitSize :: Bits b => b -> Bool
>>>
>>>
>>> I'm in favor of changing the type of bitSize, although since none of
>>> my code uses that function it's an easy position for me to take.
>>
>>
>> +1.  The Haskellish solution would let return bitSize a Maybe.
>>
>
> 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.

Thomas



More information about the Libraries mailing list