X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fharbl.git;a=blobdiff_plain;f=harbl%2Fsrc%2FNetwork%2FDNS%2FRBL%2FDomain%2FHyphen.hs;h=1e49ff2cb6e4a64b9206dde89420b22313f0ffe4;hp=65793ff57268b3e3698aa8c0a00c48f93bc2f25d;hb=014dacb6ef0e93d0e67ebb154c397e999431469f;hpb=4dd314687c806419fac1fc88c96df6541e1dff4b diff --git a/harbl/src/Network/DNS/RBL/Domain/Hyphen.hs b/harbl/src/Network/DNS/RBL/Domain/Hyphen.hs index 65793ff..1e49ff2 100644 --- a/harbl/src/Network/DNS/RBL/Domain/Hyphen.hs +++ b/harbl/src/Network/DNS/RBL/Domain/Hyphen.hs @@ -16,81 +16,33 @@ import Network.DNS.RBL.Pretty ( Pretty(..) ) --- | A wrapper around a single hyphen character. +-- | A type representing a single hyphen character. -- -- ==== _Examples_ -- --- >>> Hyphen '-' --- Hyphen '-' +-- >>> Hyphen +-- Hyphen -- --- >>> let h1 = Hyphen '-' --- >>> let h2 = Hyphen '-' +-- >>> let h1 = Hyphen +-- >>> let h2 = Hyphen -- >>> h1 == h2 -- True -- -newtype Hyphen = Hyphen Char +data Hyphen = Hyphen deriving (Eq, Show) --- | Equality is defined semantically (all hyphens are equal). +-- | Pretty-print a hyphen; they all display as \'-\'. -- -- ==== _Examples_ -- --- >>> let h1 = Hyphen '-' --- >>> let h2 = Hyphen '-' --- >>> h1 == h2 --- True --- --- If you do something stupid, that's your fault: --- --- >>> let h1 = Hyphen '-' --- >>> let h2 = Hyphen 'x' --- >>> h1 == h2 --- True --- -instance Eq Hyphen where _ == _ = True - - --- | 'Show' is defined semantically; all hyphens display as \'-\'. --- The implementation is based on what GHC derives, discovered via --- @ghci -ddump-deriv@. --- --- ==== _Examples_ --- --- >>> let h = Hyphen '-' --- >>> h --- Hyphen '-' --- --- If you do something stupid, that's your fault: --- --- >>> let h = Hyphen 'x' --- >>> h --- Hyphen '-' --- -instance Show Hyphen where - showsPrec d _ = - showParen (d > application_precedence) (showString "Hyphen '-'") - where - application_precedence = 10 - - --- | 'Pretty' is defined semantically; all hyphens display as \'-\'. --- --- ==== _Examples_ --- --- >>> let h = Hyphen '-' --- >>> pretty_print h --- - --- --- If you do something stupid, that's your fault: --- --- >>> let h = Hyphen 'x' +-- >>> let h = Hyphen -- >>> pretty_print h -- - -- instance Pretty Hyphen where pretty_show _ = "-" --- | Parse a single hyphen and wrap it in our 'Hyphen' type. +-- | Parse a single hyphen and return a 'Hyphen'. -- -- ==== _Examples_ -- @@ -99,7 +51,7 @@ instance Pretty Hyphen where pretty_show _ = "-" -- Hyphens are parsed: -- -- >>> parseTest hyphen "-" --- Hyphen '-' +-- Hyphen -- -- But not letters or digits: -- @@ -114,4 +66,4 @@ instance Pretty Hyphen where pretty_show _ = "-" -- expecting "-" -- hyphen :: Parser Hyphen -hyphen = fmap Hyphen (char '-') +hyphen = char '-' >> return Hyphen