[Haskell-cafe] Bug in Data.Bits.shift?
Seph Shewell Brockway
seph at codex.scot
Fri Oct 15 20:22:10 UTC 2021
On Thu, Oct 14, 2021 at 08:05:42PM +0000, Keith wrote:
> As currently defined, `shift x minBound` calls `shiftR` with a negative displacement.
>
> This would avoid that:
> ```
> shift x n
> | n >= 0 = shiftL x n
> | n == minBound = shiftR (shiftR x maxBound) 1
> | otherwise = shiftR x (-n)
> ```
That would require `Bits` to be a subclass of both `Ord` and `Bounded`;
currently it is only a subclass of `Eq`, and I’d want to be very cautious
about changing that.
Regards,
Seph
--
Seph Shewell Brockway, BSc MSc (Glas.)
Pronouns: she/her
More information about the Haskell-Cafe
mailing list