aboutsummaryrefslogtreecommitdiff
path: root/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
diff options
context:
space:
mode:
authorHerbert Valerio Riedel <hvr@gnu.org>2019-12-08 11:53:39 +0100
committerHerbert Valerio Riedel <hvr@gnu.org>2019-12-08 12:09:54 +0100
commitbe8b02c4e3cffe7d45b3dad0a0f071d35a274d65 (patch)
tree09e553a3714807eaf493fddb300c425b2f0d4b21 /haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
parentee05ff1ecde866e31f72e3fa4f773dca98944dc3 (diff)
Fix build-failure regression for base < 4.7
The `$>` operator definition is available only since base-4.7 which unfortunately wasn't caught before release to Hackage (but has been fixed up by a metadata-revision) This commit introduces a `CompatPrelude` module which allows to reduce the amount of CPP by ousting it to a central location, i.e. the new `CompatPrelude` module. This pattern also tends to reduce the tricks needed to silence unused import warnings. Addresses #1119
Diffstat (limited to 'haddock-library/src/Documentation/Haddock/Parser/Identifier.hs')
-rw-r--r--haddock-library/src/Documentation/Haddock/Parser/Identifier.hs28
1 files changed, 1 insertions, 27 deletions
diff --git a/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs b/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
index a83e5abf..b8afb951 100644
--- a/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser/Identifier.hs
@@ -1,4 +1,3 @@
-{-# LANGUAGE CPP #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ViewPatterns #-}
-- |
@@ -29,15 +28,8 @@ import qualified Data.Text as T
import Data.Char (isAlpha, isAlphaNum)
import Control.Monad (guard)
-import Data.Functor (($>))
-#if MIN_VERSION_base(4,9,0)
-import Text.Read.Lex (isSymbolChar)
-#else
-import Data.Char (GeneralCategory (..),
- generalCategory)
-#endif
-
import Data.Maybe
+import CompatPrelude
-- | Identifier string surrounded with namespace, opening, and closing quotes/backticks.
data Identifier = Identifier !Namespace !Char String !Char
@@ -57,24 +49,6 @@ parseValid = do
in setParserState s' $> Identifier ns op (T.unpack ident) cl
-#if !MIN_VERSION_base(4,9,0)
--- inlined from base-4.10.0.0
-isSymbolChar :: Char -> Bool
-isSymbolChar c = not (isPuncChar c) && case generalCategory c of
- MathSymbol -> True
- CurrencySymbol -> True
- ModifierSymbol -> True
- OtherSymbol -> True
- DashPunctuation -> True
- OtherPunctuation -> c `notElem` "'\""
- ConnectorPunctuation -> c /= '_'
- _ -> False
- where
- -- | The @special@ character class as defined in the Haskell Report.
- isPuncChar :: Char -> Bool
- isPuncChar = (`elem` (",;()[]{}`" :: String))
-#endif
-
-- | Try to parse a delimited identifier off the front of the given input.
--
-- This tries to match as many valid Haskell identifiers/operators as possible,