-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)
+
+
+instance Maskable Octet where
+ apply_mask oct Eight _ = oct
+
+ apply_mask oct Seven bit =
+ oct { b8 = bit }
+
+ apply_mask oct Six bit =
+ oct { b8 = bit, b7 = bit }
+
+ apply_mask oct Five bit =
+ oct { b8 = bit, b7 = bit, b6 = bit }
+
+ apply_mask oct Four bit =
+ oct { b8 = bit, b7 = bit, b6 = bit, b5 = bit }