From: Michael Orlitzky Date: Mon, 13 Jul 2015 14:37:59 +0000 (-0400) Subject: Remove underlying Char from Hyphen type. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=014dacb6ef0e93d0e67ebb154c397e999431469f;p=dead%2Fharbl.git Remove underlying Char from Hyphen type. --- 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 diff --git a/harbl/src/Network/DNS/RBL/Domain/LdhStr.hs b/harbl/src/Network/DNS/RBL/Domain/LdhStr.hs index 28deb1f..85591eb 100644 --- a/harbl/src/Network/DNS/RBL/Domain/LdhStr.hs +++ b/harbl/src/Network/DNS/RBL/Domain/LdhStr.hs @@ -48,7 +48,7 @@ import Network.DNS.RBL.Reversible ( Reversible(..) ) -- -- >>> let (Right r) = parse let_dig_hyp "" "-" -- >>> LdhStrSingleLdh r --- LdhStrSingleLdh (LetDigHypHyphen (Hyphen '-')) +-- LdhStrSingleLdh (LetDigHypHyphen Hyphen) -- -- We can create an 'LdhStrMultipleLdh' from multiple (let-dig-hyp) -- characters: @@ -168,7 +168,7 @@ instance Reversible LdhStr where -- LdhStrSingleLdh (LetDigHypLetDig (LetDigDigit (Digit '0'))) -- -- >>> parseTest ldh_str "-" --- LdhStrSingleLdh (LetDigHypHyphen (Hyphen '-')) +-- LdhStrSingleLdh (LetDigHypHyphen Hyphen) -- -- As well as strings of them: -- diff --git a/harbl/src/Network/DNS/RBL/Domain/LetDigHyp.hs b/harbl/src/Network/DNS/RBL/Domain/LetDigHyp.hs index 06e420a..270951a 100644 --- a/harbl/src/Network/DNS/RBL/Domain/LetDigHyp.hs +++ b/harbl/src/Network/DNS/RBL/Domain/LetDigHyp.hs @@ -42,7 +42,7 @@ import Network.DNS.RBL.Pretty ( Pretty(..) ) -- -- >>> let (Right r) = parse hyphen "" "-" -- >>> LetDigHypHyphen r --- LetDigHypHyphen (Hyphen '-') +-- LetDigHypHyphen Hyphen -- data LetDigHyp = LetDigHypLetDig LetDig | @@ -90,7 +90,7 @@ instance Pretty LetDigHyp where -- LetDigHypLetDig (LetDigDigit (Digit '7')) -- -- >>> parseTest let_dig_hyp "-" --- LetDigHypHyphen (Hyphen '-') +-- LetDigHypHyphen Hyphen -- -- However, an underscore (for example) is not: --