]> gitweb.michael.orlitzky.com - dead/harbl.git/commitdiff
Remove underlying Char from Hyphen type.
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 13 Jul 2015 14:37:59 +0000 (10:37 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 13 Jul 2015 14:37:59 +0000 (10:37 -0400)
harbl/src/Network/DNS/RBL/Domain/Hyphen.hs
harbl/src/Network/DNS/RBL/Domain/LdhStr.hs
harbl/src/Network/DNS/RBL/Domain/LetDigHyp.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_
 --
 --
 --   ==== _Examples_
 --
---   >>> Hyphen '-'
---   Hyphen '-'
+--   >>> Hyphen
+--   Hyphen
 --
 --
---   >>> let h1 = Hyphen '-'
---   >>> let h2 = Hyphen '-'
+--   >>> let h1 = Hyphen
+--   >>> let h2 = Hyphen
 --   >>> h1 == h2
 --   True
 --
 --   >>> 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_
 --
 --
 --   ==== _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 _ = "-"
 
 
 --   >>> 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_
 --
 --
 --   ==== _Examples_
 --
@@ -99,7 +51,7 @@ instance Pretty Hyphen where pretty_show _ = "-"
 --   Hyphens are parsed:
 --
 --   >>> parseTest hyphen "-"
 --   Hyphens are parsed:
 --
 --   >>> parseTest hyphen "-"
---   Hyphen '-'
+--   Hyphen
 --
 --   But not letters or digits:
 --
 --
 --   But not letters or digits:
 --
@@ -114,4 +66,4 @@ instance Pretty Hyphen where pretty_show _ = "-"
 --   expecting "-"
 --
 hyphen :: Parser Hyphen
 --   expecting "-"
 --
 hyphen :: Parser Hyphen
-hyphen = fmap Hyphen (char '-')
+hyphen = char '-' >> return Hyphen
index 28deb1fdee70a1847658c9f547293ddd3dfdbae4..85591eb6de253e700fc572d807da941367ba5dbe 100644 (file)
@@ -48,7 +48,7 @@ import Network.DNS.RBL.Reversible ( Reversible(..) )
 --
 --   >>> let (Right r) = parse let_dig_hyp "" "-"
 --   >>> LdhStrSingleLdh r
 --
 --   >>> 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:
 --
 --   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 (LetDigHypLetDig (LetDigDigit (Digit '0')))
 --
 --   >>> parseTest ldh_str "-"
---   LdhStrSingleLdh (LetDigHypHyphen (Hyphen '-'))
+--   LdhStrSingleLdh (LetDigHypHyphen Hyphen)
 --
 --   As well as strings of them:
 --
 --
 --   As well as strings of them:
 --
index 06e420a3a0c94d615f7926084029967b0f5d6858..270951a46547721c55c6b9370de3bcf62fc01a04 100644 (file)
@@ -42,7 +42,7 @@ import Network.DNS.RBL.Pretty ( Pretty(..) )
 --
 --   >>> let (Right r) = parse hyphen "" "-"
 --   >>> LetDigHypHyphen r
 --
 --   >>> let (Right r) = parse hyphen "" "-"
 --   >>> LetDigHypHyphen r
---   LetDigHypHyphen (Hyphen '-')
+--   LetDigHypHyphen Hyphen
 --
 data LetDigHyp =
   LetDigHypLetDig LetDig |
 --
 data LetDigHyp =
   LetDigHypLetDig LetDig |
@@ -90,7 +90,7 @@ instance Pretty LetDigHyp where
 --   LetDigHypLetDig (LetDigDigit (Digit '7'))
 --
 --   >>> parseTest let_dig_hyp "-"
 --   LetDigHypLetDig (LetDigDigit (Digit '7'))
 --
 --   >>> parseTest let_dig_hyp "-"
---   LetDigHypHyphen (Hyphen '-')
+--   LetDigHypHyphen Hyphen
 --
 --   However, an underscore (for example) is not:
 --
 --
 --   However, an underscore (for example) is not:
 --