@@ -13,11 +13,8 @@
1313-- such as URL pieces, headers and query parameters.
1414module Web.Internal.HttpApiData where
1515
16−#if __GLASGOW_HASKELL__ < 710
17−import Control.Applicative
18−import Data.Foldable (Foldable)
19−import Data.Traversable (Traversable (traverse))
20−#endif
16+import Prelude ()
17+import Prelude.Compat
2118
2219import Control.Arrow (left, (&&&))
2320import Control.Monad ((<=<))
@@ -33,22 +30,19 @@ import Data.Word
3330
3431import Data.Text (Text)
3532import qualified Data.Text as T
36−import Data.Text.Encoding (decodeUtf8With, decodeUtf8', encodeUtf8)
33+import Data.Text.Encoding (decodeUtf8', decodeUtf8With,
34+ encodeUtf8)
3735import Data.Text.Encoding.Error (lenientDecode)
3836import qualified Data.Text.Lazy as L
3937import Data.Text.Read (Reader, decimal, rational,
4038 signed)
4139
4240import Data.Time
43−#if __GLASGOW_HASKELL__ < 710
4441import Data.Time.Locale.Compat
45−#endif
4642import Data.Version
4743
48−#if MIN_VERSION_base(4,8,0)
4944import Data.Void
5045import Numeric.Natural
51−#endif
5246
5347import Text.ParserCombinators.ReadP (readP_to_S)
5448import Text.Read (readMaybe)
@@ -432,10 +426,8 @@ instance ToHttpApiData Version where
432426 toUrlPiece = T.pack . showVersion
433427 toEncodedUrlPiece = unsafeToEncodedUrlPiece
434428
435−#if MIN_VERSION_base(4,8,0)
436429instance ToHttpApiData Void where toUrlPiece = absurd
437430instance ToHttpApiData Natural where toUrlPiece = showt; toEncodedUrlPiece = unsafeToEncodedUrlPiece
438−#endif
439431
440432instance ToHttpApiData Bool where toUrlPiece = showTextData; toEncodedUrlPiece = unsafeToEncodedUrlPiece
441433instance ToHttpApiData Ordering where toUrlPiece = showTextData; toEncodedUrlPiece = unsafeToEncodedUrlPiece
@@ -566,7 +558,7 @@ instance FromHttpApiData Char where
566558 parseUrlPiece s =
567559 case T.uncons s of
568560 Just (c, s') | T.null s' -> pure c
569− _ -> defaultParseError s
561+ _ -> defaultParseError s
570562
571563-- |
572564-- >>> showVersion <$> parseUrlPiece "1.2.3"
@@ -577,7 +569,6 @@ instance FromHttpApiData Version where
577569 ((x, ""):_) -> pure x
578570 _ -> defaultParseError s
579571
580−#if MIN_VERSION_base(4,8,0)
581572-- | Parsing a @'Void'@ value is always an error, considering @'Void'@ as a data type with no constructors.
582573instance FromHttpApiData Void where
583574 parseUrlPiece _ = Left "Void cannot be parsed!"
@@ -588,7 +579,6 @@ instance FromHttpApiData Natural where
588579 if n < 0
589580 then Left ("underflow: " <> s <> " (should be a non-negative integer)")
590581 else Right (fromInteger n)
591−#endif
592582
593583instance FromHttpApiData Bool where parseUrlPiece = parseBoundedUrlPiece
594584instance FromHttpApiData Ordering where parseUrlPiece = parseBoundedUrlPiece