Confusion over bitSize, bitSizeMaybe, and finiteBitSize

Henning Thielemann lemming at henning-thielemann.de
Mon Jun 22 09:04:32 UTC 2020


On Sun, 21 Jun 2020, chessai wrote:

> The documentation for these functions in Data.Bits say that these
> functions do not evaluate their arguments. This wording is a bit
> strange to me, since it seems that does not exactly mean that any such
> implementation _must not_ evaluate its argument. This may be an issue
> when dealing with types whose inhabitants have finite but not
> necessarily fixed sizes. For example, there is a valid Bits instance
> for strict ByteString, which is finite but not fixed-size.

Documentation of bitSizeMaybe says:

Returns Nothing for types that do not have a fixed bitsize, like Integer.

So, no evaluation of argument is necessary.

Of course, it would have been better to use a Proxy.


More information about the Libraries mailing list