+ apply_mask oct Three bit =
+ oct { b8 = bit, b7 = bit, b6 = bit, b5 = bit, b4 = bit }
+
+ apply_mask oct Two bit =
+ oct { b8 = bit, b7 = bit, b6 = bit, b5 = bit, b4 = bit, b3 = bit }
+
+ apply_mask oct Maskbits.One bit =
+ oct { b8 = bit, b7 = bit, b6 = bit, b5 = bit,
+ b4 = bit, b3 = bit, b2 = bit }
+
+ apply_mask oct Maskbits.Zero bit =
+ oct { b8 = bit, b7 = bit, b6 = bit, b5 = bit,
+ b4 = bit, b3 = bit, b2 = bit, b1 = bit }
+
+ -- The Maskbits must be in [Eight..ThirtyTwo].
+ apply_mask oct _ _ = oct
+
+
+-- | Convert each bit to its integer value, and multiply by the
+-- appropriate power of two. Sum them up, and we should get an integer
+-- between 0 and 255.