1 -- | OK, I lied about "Network.DNS.RBL.Domain.Digit" and
2 -- "Network.DNS.RBL.Domain.Letter" being the simplest modules you'd
3 -- ever see. Because this is. It contains the 'Hyphen' type and a
4 -- Parsec parser to parse one. We don't export its constructor because
5 -- then you could do something dumb like stick a letter inside one.
7 module Network.DNS.RBL.Domain.Hyphen (
12 import Text.Parsec ( char )
13 import Text.Parsec.String ( Parser )
15 import Network.DNS.RBL.Pretty ( Pretty(..) )
19 -- | A type representing a single hyphen character.
26 -- >>> let h1 = Hyphen
27 -- >>> let h2 = Hyphen
31 data Hyphen = Hyphen deriving (Eq, Show)
34 -- | Pretty-print a hyphen; they all display as \'-\'.
42 instance Pretty Hyphen where pretty_show _ = "-"
45 -- | Parse a single hyphen and return a 'Hyphen'.
49 -- >>> import Text.Parsec ( parseTest )
51 -- Hyphens are parsed:
53 -- >>> parseTest hyphen "-"
56 -- But not letters or digits:
58 -- >>> parseTest hyphen "1"
59 -- parse error at (line 1, column 1):
63 -- >>> parseTest hyphen "x"
64 -- parse error at (line 1, column 1):
68 hyphen :: Parser Hyphen
69 hyphen = char '-' >> return Hyphen