Make bitwise operators a typeclass
The WebGPU API uses more specialized flavors of Int like unsigned long and unsinged long long. It's practical to newtype these over Int, but then, when doing bitmasks, one can't get the underlying Int without exposing the newtype constructor. If Bitwise operators like and, and or were all in a typeclass, this would allow us to derive newtype and would allow other specializations.
That is one approach. Another is that the WebGPU library could define its own type class for doing this to make it easier on the library.
The reason why I'm suggesting this is that I'm not sure where else this need arises other than in that library. So, is it really worth introducing the type class here? Or does it suffice to put it there?
Also, those operators have special compiler support, so just adding a type class may require updates to the compiler (I don't know for sure, but it's something that would need to be checked).
Here are some more uses cases for it
- https://pursuit.purescript.org/packages/purescript-js-bigints/2.2.1/docs/JS.BigInt
- https://pursuit.purescript.org/packages/purescript-longs/0.1.1/docs/Data.Long.Bits
- https://pursuit.purescript.org/packages/purescript-int-53/4.0.0/docs/Data.Int53 (this one doesn't have the bitwise operators yet but could probably get them)
i'm also in favor of a typeclass like this one https://hackage.haskell.org/package/base-4.18.1.0/docs/Data-Bits.html