-- | OK, I lied about "Network.DNS.RBL.Domain.Digit" and -- "Network.DNS.RBL.Domain.Letter" being the simplest modules you'd -- ever see. Because this is. It contains the 'Hyphen' type and a -- Parsec parser to parse one. We don't export its constructor because -- then you could do something dumb like stick a letter inside one. -- module Network.DNS.RBL.Domain.Hyphen ( Hyphen, hyphen ) where import Text.Parsec ( char ) import Text.Parsec.String ( Parser ) import Network.DNS.RBL.Pretty ( Pretty(..) ) -- | A type representing a single hyphen character. -- -- ==== _Examples_ -- -- >>> Hyphen -- Hyphen -- -- >>> let h1 = Hyphen -- >>> let h2 = Hyphen -- >>> h1 == h2 -- True -- data Hyphen = Hyphen deriving (Eq, Show) -- | Pretty-print a hyphen; they all display as \'-\'. -- -- ==== _Examples_ -- -- >>> let h = Hyphen -- >>> pretty_print h -- - -- instance Pretty Hyphen where pretty_show _ = "-" -- | Parse a single hyphen and return a 'Hyphen'. -- -- ==== _Examples_ -- -- >>> import Text.Parsec ( parseTest ) -- -- Hyphens are parsed: -- -- >>> parseTest hyphen "-" -- Hyphen -- -- But not letters or digits: -- -- >>> parseTest hyphen "1" -- parse error at (line 1, column 1): -- unexpected "1" -- expecting "-" -- -- >>> parseTest hyphen "x" -- parse error at (line 1, column 1): -- unexpected "x" -- expecting "-" -- hyphen :: Parser Hyphen hyphen = char '-' >> return Hyphen