Proposol: make Data.Bits algebraic

Zemyla zemyla at gmail.com
Tue Mar 12 03:57:37 UTC 2019


Bits can't be algebraic, because the testBit function exists. Anything
where finiteBitsMaybe returns Just (a number) can be tested for
equality, and even if it returns Nothing, it can still be tested for
inequality, or equality up to a certain index.

On Mon, Mar 11, 2019 at 4:49 PM Johnson-Freyd, Philip Alden via
Libraries <libraries at haskell.org> wrote:
>
> Hello,
>
> The current version of Data.Bits is non-algebraic, in so far as the Bits class has
> 1. a superclass constraint on `Eq`
> 2. operations `testBit` and `isSigned` which return `Bool`.
>
>
>
> This is quite annoying, as myriad potential uses of the Bits class cover types for which these concrete observations are not possible. It leads to comments like the following in SBV:
>
> -- | This instance is only defined so that we can define an instance for
>
> -- 'Data.Bits.Bits'. '==' and '/=' simply throw an error. Use
>
> -- 'Data.SBV.EqSymbolic' instead.
>
> We had this same issue for `Num` for years, until it eventually got fixed. And it would be nice to fix the situation for `Bits` as well.
>
> There are other aspects of the Bits API which are pretty clunky, but this is the one that is often a show stopper.
>
>
> Philip
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


More information about the Libraries mailing list