--- | 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_
--
-- Hyphens are parsed:
--
-- >>> parseTest hyphen "-"
--- Hyphen '-'
+-- Hyphen
--
-- But not letters or digits:
--
-- expecting "-"
--
hyphen :: Parser Hyphen
-hyphen = fmap Hyphen (char '-')
+hyphen = char '-' >> return Hyphen
--
-- >>> 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:
-- LdhStrSingleLdh (LetDigHypLetDig (LetDigDigit (Digit '0')))
--
-- >>> parseTest ldh_str "-"
--- LdhStrSingleLdh (LetDigHypHyphen (Hyphen '-'))
+-- LdhStrSingleLdh (LetDigHypHyphen Hyphen)
--
-- As well as strings of them:
--
--
-- >>> let (Right r) = parse hyphen "" "-"
-- >>> LetDigHypHyphen r
--- LetDigHypHyphen (Hyphen '-')
+-- LetDigHypHyphen Hyphen
--
data LetDigHyp =
LetDigHypLetDig LetDig |
-- LetDigHypLetDig (LetDigDigit (Digit '7'))
--
-- >>> parseTest let_dig_hyp "-"
--- LetDigHypHyphen (Hyphen '-')
+-- LetDigHypHyphen Hyphen
--
-- However, an underscore (for example) is not:
--