Confusion over bitSize, bitSizeMaybe, and finiteBitSize

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. My question is, should the wording be changed to be a bit clearer? Or should this restriction exist in the first place?

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.
participants (2)
-
chessai
-
Henning Thielemann