import Test.QuickCheck
--- A type representing the number of bits in a CIDR netmask.
+-- | A type representing the number of bits in a CIDR netmask.
data Maskbits =
Zero
| One
maskbits_from_int 32 = Just ThirtyTwo
maskbits_from_int _ = Nothing
+
+-- | Convert a String to Maskbits, if possible.
maskbits_from_string :: String -> Maybe Maskbits
maskbits_from_string s =
case (reads s :: [(Int, String)]) of
+-- | Maskbits are just natural numbers, this returns the previous one.
decrement :: Maskbits -> Maskbits
decrement Zero = Zero
decrement One = Zero