You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Bits and FiniteBits documentation, bitSize, bitSizeMaybe, and finiteBitSize say that they do not evaluate their arguments. This makes sense for fixed-size types. For something like ByteString though, we need to get the length of the ByteString (e.g. finiteBitSize x = 8 * B.length x). However quickcheck-classes makes the assumption that finiteBitSize will never evaluate its argument, since it passes undefined to it everywhere. It is not clear to me that the documentation for Data.Bits is indicating that a valid implementation of these functions must not evaluate its argument, or if when defining these classes, only fixed-width types were in mind (and not necessarily just finite-sized types, like strict ByteString).
The text was updated successfully, but these errors were encountered:
Return the number of bits in the type of the argument. The actual value of the argument is ignored. The function bitSize is undefined for types that do not have a fixed bitsize, like Integer.
I've always read this to mean that bitSize must not evaluate its argument. That's what every instance in base does. When Bits was originally written, at least one variable-width type must have been in mind: Integer. However, I find using Bits for variable-length types dubious in general. For the hypothetical ByteString instance, what would .|. and .&. do? Truncate to the length of the shorter argument? See this reddit thread, where Edward has some thoughts on the topic, and see haskell/bytestring#110, which the thread references.
In the Bits and FiniteBits documentation,
bitSize
,bitSizeMaybe
, andfiniteBitSize
say that they do not evaluate their arguments. This makes sense for fixed-size types. For something like ByteString though, we need to get the length of the ByteString (e.g.finiteBitSize x = 8 * B.length x
). However quickcheck-classes makes the assumption that finiteBitSize will never evaluate its argument, since it passesundefined
to it everywhere. It is not clear to me that the documentation for Data.Bits is indicating that a valid implementation of these functions must not evaluate its argument, or if when defining these classes, only fixed-width types were in mind (and not necessarily just finite-sized types, like strict ByteString).The text was updated successfully, but these errors were encountered: