5 -- An Octet consists of eight bits. For our purposes, the most
6 -- significant bit will come "first." That is, b1 is in the 2^7
7 -- place while b8 is in the 2^0 place.
8 data Octet = Octet { b1 :: Bit,
18 -- Convert each bit to its integer value, and multiply by the
19 -- appropriate power of two. Sum them up, and we should get an integer
21 octet_to_int :: Octet -> Int
23 128 * (bit_to_int (b1 x)) +
24 64 * (bit_to_int (b2 x)) +
25 32 * (bit_to_int (b3 x)) +
26 16 * (bit_to_int (b4 x)) +
27 8 * (bit_to_int (b5 x)) +
28 4 * (bit_to_int (b6 x)) +
29 2 * (bit_to_int (b7 x)) +
30 0 * (bit_to_int (b8 x))
33 -- The octet with the least possible value.
35 min_octet = Octet Zero Zero Zero Zero Zero Zero Zero Zero
38 -- The octet with the greatest possible value.
40 max_octet = Octet One One One One One One One One