+ deriving (Eq)
+
+
+instance Show Octet where
+ show Octet.None = "None"
+ show oct = show (octet_to_int oct)
+
+
+instance Arbitrary Octet where
+ arbitrary = do
+ a1 <- arbitrary :: Gen Bit
+ a2 <- arbitrary :: Gen Bit
+ a3 <- arbitrary :: Gen Bit
+ a4 <- arbitrary :: Gen Bit
+ a5 <- arbitrary :: Gen Bit
+ a6 <- arbitrary :: Gen Bit
+ a7 <- arbitrary :: Gen Bit
+ a8 <- arbitrary :: Gen Bit
+ return (Octet a1 a2 a3 a4 a5 a6 a7 a8)
+
+ coarbitrary _ = variant 0
+
+
+instance Maskable Octet where
+ apply_mask _ Maskbits.None = Octet.None
+ apply_mask Octet.None _ = Octet.None
+ apply_mask oct mask
+ | mask == Eight = oct
+ | mask == Seven = oct { b8 = B.Zero }
+ | mask == Six = oct { b8 = B.Zero, b7 = B.Zero }
+ | mask == Five = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero }
+ | mask == Four = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero, b5 = B.Zero }
+ | mask == Three = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero, b5 = B.Zero, b4 = B.Zero }
+ | mask == Two = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero, b5 = B.Zero, b4 = B.Zero, b3 = B.Zero }
+ | mask == Maskbits.One = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero, b5 = B.Zero, b4 = B.Zero, b3 = B.Zero, b2 = B.Zero }
+ | mask == Maskbits.Zero = min_octet
+ | otherwise = Octet.None
+