6 -- A type representing the number of bits in a CIDR netmask.
7 data Maskbits = None | Maskbits Int
11 -- There are only 32 bits in an IPv4 address, so there
12 -- can't be more bits than that in the mask.
13 maskbits_from_int :: Int -> Maskbits
14 maskbits_from_int x | (x < 0) || (x > 32) = None
15 | otherwise = Maskbits x
18 maskbits_from_string :: String -> Maskbits
19 maskbits_from_string s =
20 case (reads s :: [(Int, String)]) of
22 x:_ -> maskbits_from_int (fst x)