
Yitzchak Gale schrieb:
Henning Thielemann wrote:
Is NumLazyByteString a newtype around Bytestring.Lazy that interprets the bit stream represented by the ByteString as integer?
Thomas DuBuisson wrote:
Not exactly. There is not newtype wrapper. NumLazyByteString is: instance Num L.ByteString where ...
Are you absolutely certain that this is the one and only canonical instance that can ever exist that makes sense? Otherwise, please use a newtype wrapper.
I think there are at least two reasonable instance: One that treats all bytes individually and one that treats the whole bytestring as one binary number. Btw. I assume that in order to be lazy when computing exactly with integers you must start with the least significant bits, right? In my implementation of Positional numbers I start with the most significant digits since I implemented fractional numbers and I must use a redundant set of digits in order to stay lazy in case of carries.
The reason for this is one of the few remaining major warts in Haskell - that there is absolutely *no way* to prevent the export of instances from a module that you import.
Since this is a common issue a wrote a Wiki article on it: https://haskell.org/haskellwiki/Orphan_instance