]> gitweb.michael.orlitzky.com - dead/harbl.git/blobdiff - harbl/src/Network/DNS/RBL/Domain/Hyphen.hs
Remove underlying Char from Hyphen type.
[dead/harbl.git] / harbl / src / Network / DNS / RBL / Domain / Hyphen.hs
index 65793ff57268b3e3698aa8c0a00c48f93bc2f25d..1e49ff2cb6e4a64b9206dde89420b22313f0ffe4 100644 (file)
@@ -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