I have a type that basically acts as a tag on another data type:
import Data.Word
data RijndaelField = RF Word8
I want RijndaelField to "inherit" the Word8 instance of Bits in the simplest way possible:
import Data.Bits
instance Bits RijndaelField where
RF a .&. RF b = RF $ a .&. b
RF a .|. RF b = RF $ a .|. b
RF a `xor` RF b = RF $ a `xor` b
complement (RF a) = RF $ complement a
shift (RF a) n = RF $ shift a n
rotate (RF a) n = RF $ rotate a n
bitSize (RF a) = bitSize a
isSigned (RF a) = isSigned a
testBit (RF a) n = testBit a n
bit n = RF $ bit n
popCount (RF a) = popCount a
Is there a shorter way to express that relation between RijndaelField and Word8?