Proposal: Add hasBitSize to Data.Bits.Bits
ekmett at gmail.com
Thu Aug 23 01:49:49 CEST 2012
To summarize the design we've converged upon during the discussion period
We want to add
> class Bits b where
> bitSizeMaybe :: b -> Maybe Int
and deprecate, but not remove bitSize this iteration, and make a separate
class FiniteBits for things with a finite, fixed number of bits:
> class Bits b => FiniteBits b where
> finiteBitSize :: b -> Int
> finiteBitSize = bitSize
The former permits safer access to bitSize while allowing applications that
can deal with infinite structures to run, the latter permits safer access
to bitSize while allowing applications that cannot deal with infinite
structures to know that they aren't dealing with Integer or somebody's
Natural data type.
On Wed, Aug 22, 2012 at 5:19 PM, Ian Lynagh <ian at well-typed.com> wrote:
> On Mon, Aug 13, 2012 at 06:42:54PM -0400, Edward Kmett wrote:
> > class Bits b where
> > perhapsBitSize :: b -> Maybe Int
> > ...
> > I am not wedded to the perhapsBitSize name
> I've lost track of where this proposal is, but if we do end up with a
> Maybe function then I think it should be called maybeBitSize or
> bitSizeMaybe. The only analogous example in the core libraries that I
> can think of OTTOMH is Text.Read.readMaybe.
> Libraries mailing list
> Libraries at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries