on master help sign in
Drop pre-GHC-7.8 support (#743)

This commit makes only non-breaking cleanups. Stricter lower-bounds for - __GLASGOW_HASKELL__ - base - bytestring - template-haskell Allows to remove some CPP

commit4d3767c18ef6c3b4fe5b986fe39b244759f1359e authorOleg Grenrus <oleg.grenrus@iki.fi> dateSun 1 Dec 2019, 07:44 (7 years ago) parent5ad68a0
16 files changed+17−197
.travis.yml−8 Data/Aeson/Compat.hs−16 Data/Aeson/TH.hs−34 Data/Aeson/Types/FromJSON.hs+8−40 Data/Aeson/Types/ToJSON.hs+3−41 aeson.cabal+4−10 attoparsec-iso8601/Data/Attoparsec/Time/Internal.hs−20 attoparsec-iso8601/attoparsec-iso8601.cabal+1−1 benchmarks/aeson-benchmarks.cabal−1 cabal.project+1 tests/Encoders.hs−6 tests/Instances.hs−3 tests/PropertyGeneric.hs−8 tests/PropertyKeys.hs−3 tests/SerializationFormatSpec.hs−4 tests/Types.hs−2
.travis.yml−8
@@ -65,14 +65,6 @@ matrix:
6565 compiler: ": #GHC 7.8.4"
6666 addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
6767
68− - env: BUILD=cabal CABALVER=1.18 GHCVER=7.6.3
69− compiler: ": #GHC 7.6.3"
70− addons: {apt: {packages: [cabal-install-1.18,ghc-7.6.3], sources: [hvr-ghc]}}
71−
72− - env: BUILD=cabal CABALVER=1.18 GHCVER=7.4.2
73− compiler: ": #GHC 7.4.2"
74− addons: {apt: {packages: [cabal-install-1.18,ghc-7.4.2], sources: [hvr-ghc]}}
75−
7668before_install:
7769 - unset CC
7870 - export PATH=$HOME/.local/bin:/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
Data/Aeson/Compat.hsdeleted−16
@@ -1,16 +0,0 @@
1−{-# LANGUAGE CPP #-}
2−
3−module Data.Aeson.Compat
4− (
5− fromStrict
6− ) where
7−
8−import qualified Data.ByteString as S
9−import qualified Data.ByteString.Lazy as L
10−
11−fromStrict :: S.ByteString -> L.ByteString
12−#if MIN_VERSION_bytestring(0, 9, 2)
13−fromStrict = L.fromChunks . (:[])
14−#else
15−fromStrict = L.fromStrict
16−#endif
Data/Aeson/TH.hs−34
@@ -135,15 +135,8 @@ import Data.Map (Map)
135135import Data.Maybe (catMaybes, fromMaybe, mapMaybe)
136136import qualified Data.Monoid as Monoid
137137import Data.Set (Set)
138−#if MIN_VERSION_template_haskell(2,8,0)
139138import Language.Haskell.TH hiding (Arity)
140−#else
141−import Language.Haskell.TH
142−#endif
143139import Language.Haskell.TH.Datatype
144−#if MIN_VERSION_template_haskell(2,7,0) && !(MIN_VERSION_template_haskell(2,8,0))
145−import Language.Haskell.TH.Lib (starK)
146−#endif
147140#if MIN_VERSION_template_haskell(2,8,0) && !(MIN_VERSION_template_haskell(2,10,0))
148141import Language.Haskell.TH.Syntax (mkNameG_tc)
149142#endif
@@ -1590,21 +1583,13 @@ type TyVarMap = Map Name (Name, Name)
15901583-- | Returns True if a Type has kind *.
15911584hasKindStar :: Type -> Bool
15921585hasKindStar VarT{} = True
1593−#if MIN_VERSION_template_haskell(2,8,0)
15941586hasKindStar (SigT _ StarT) = True
1595−#else
1596−hasKindStar (SigT _ StarK) = True
1597−#endif
15981587hasKindStar _ = False
15991588
16001589-- Returns True is a kind is equal to *, or if it is a kind variable.
16011590isStarOrVar :: Kind -> Bool
1602−#if MIN_VERSION_template_haskell(2,8,0)
16031591isStarOrVar StarT = True
16041592isStarOrVar VarT{} = True
1605−#else
1606−isStarOrVar StarK = True
1607−#endif
16081593isStarOrVar _ = False
16091594
16101595-- Generate a list of fresh names with a common prefix, and numbered suffixes.
@@ -1662,9 +1647,7 @@ isTyFamily (ConT n) = do
16621647#else
16631648 FamilyI (FamilyD TypeFam _ _ _) _ -> True
16641649#endif
1665−#if MIN_VERSION_template_haskell(2,9,0)
16661650 FamilyI ClosedTypeFamilyD{} _ -> True
1667−#endif
16681651 _ -> False
16691652isTyFamily _ = return False
16701653
@@ -1692,9 +1675,7 @@ mentionsName = go
16921675 go :: Type -> [Name] -> Bool
16931676 go (AppT t1 t2) names = go t1 names || go t2 names
16941677 go (SigT t _k) names = go t names
1695−#if MIN_VERSION_template_haskell(2,8,0)
16961678 || go _k names
1697−#endif
16981679 go (VarT n) names = n `elem` names
16991680 go _ _ = False
17001681
@@ -1750,23 +1731,14 @@ uncurryTy t = ([], t :| [])
17501731
17511732-- | Like uncurryType, except on a kind level.
17521733uncurryKind :: Kind -> NonEmpty Kind
1753−#if MIN_VERSION_template_haskell(2,8,0)
17541734uncurryKind = snd . uncurryTy
1755−#else
1756−uncurryKind (ArrowK k1 k2) = k1 <| uncurryKind k2
1757−uncurryKind k = k :| []
1758−#endif
17591735
17601736createKindChain :: Int -> Kind
17611737createKindChain = go starK
17621738 where
17631739 go :: Kind -> Int -> Kind
17641740 go k 0 = k
1765−#if MIN_VERSION_template_haskell(2,8,0)
17661741 go k !n = go (AppT (AppT ArrowT StarT) k) (n - 1)
1767−#else
1768− go k !n = go (ArrowK StarK k) (n - 1)
1769−#endif
17701742
17711743-- | Makes a string literal expression from a constructor's name.
17721744conNameExp :: Options -> ConstructorInfo -> Q Exp
@@ -1820,11 +1792,7 @@ canEtaReduce remaining dropped =
18201792-------------------------------------------------------------------------------
18211793
18221794applySubstitutionKind :: Map Name Kind -> Type -> Type
1823−#if MIN_VERSION_template_haskell(2,8,0)
18241795applySubstitutionKind = applySubstitution
1825−#else
1826−applySubstitutionKind _ t = t
1827−#endif
18281796
18291797substNameWithKind :: Name -> Kind -> Type -> Type
18301798substNameWithKind n k = applySubstitutionKind (M.singleton n k)
@@ -1988,9 +1956,7 @@ data StarKindStatus = NotKindStar
19881956canRealizeKindStar :: Type -> StarKindStatus
19891957canRealizeKindStar t = case t of
19901958 _ | hasKindStar t -> KindStar
1991−#if MIN_VERSION_template_haskell(2,8,0)
19921959 SigT _ (VarT k) -> IsKindVar k
1993−#endif
19941960 _ -> NotKindStar
19951961
19961962-- | Returns 'Just' the kind variable 'Name' of a 'StarKindStatus' if it exists.
Data/Aeson/Types/FromJSON.hs+8−40
@@ -7,16 +7,13 @@
77{-# LANGUAGE MultiParamTypeClasses #-}
88{-# LANGUAGE NoImplicitPrelude #-}
99{-# LANGUAGE OverloadedStrings #-}
10+{-# LANGUAGE PolyKinds #-}
1011{-# LANGUAGE RecordWildCards #-}
1112{-# LANGUAGE ScopedTypeVariables #-}
1213{-# LANGUAGE TypeOperators #-}
1314{-# LANGUAGE UndecidableInstances #-}
1415{-# LANGUAGE ViewPatterns #-}
1516
16−#if __GLASGOW_HASKELL__ >= 706
17−{-# LANGUAGE PolyKinds #-}
18−#endif
19−
2017#include "incoherent-compat.h"
2118#include "overlapping-compat.h"
2219
@@ -120,9 +117,9 @@ import GHC.Generics
120117import Numeric.Natural (Natural)
121118import Text.ParserCombinators.ReadP (readP_to_S)
122119import Unsafe.Coerce (unsafeCoerce)
123−import qualified Data.Aeson.Compat as Compat
124120import qualified Data.Aeson.Parser.Time as Time
125121import qualified Data.Attoparsec.ByteString.Char8 as A (endOfInput, parseOnly, scientific)
122+import qualified Data.ByteString.Lazy as L
126123import qualified Data.DList as DList
127124import qualified Data.HashMap.Strict as H
128125import qualified Data.HashSet as HashSet
@@ -157,18 +154,8 @@ import qualified Data.Primitive.UnliftedArray as PM
157154import qualified Data.Primitive.PrimArray as PM
158155#endif
159156
160−#ifndef HAS_COERCIBLE
161−#define HAS_COERCIBLE (__GLASGOW_HASKELL__ >= 707)
162−#endif
163157
164−#if HAS_COERCIBLE
165158import Data.Coerce (Coercible, coerce)
166−coerce' :: Coercible a b => a -> b
167−coerce' = coerce
168−#else
169−coerce' :: a -> b
170−coerce' = unsafeCoerce
171−#endif
172159
173160parseIndexedJSON :: (Value -> Parser a) -> Int -> Value -> Parser a
174161parseIndexedJSON p idx value = p value <?> Index idx
@@ -440,11 +427,7 @@ class FromJSONKey a where
440427-- At the moment this type is intentionally not exported. 'FromJSONKeyFunction'
441428-- can be inspected, but cannot be constructed.
442429data CoerceText a where
443−#if HAS_COERCIBLE
444430 CoerceText :: Coercible Text a => CoerceText a
445−#else
446− CoerceText :: CoerceText a
447−#endif
448431
449432-- | This type is related to 'ToJSONKeyFunction'. If 'FromJSONKeyValue' is used in the
450433-- 'FromJSONKey' instance, then 'ToJSONKeyValue' should be used in the 'ToJSONKey'
@@ -464,7 +447,7 @@ data FromJSONKeyFunction a
464447
465448-- | Only law abiding up to interpretation
466449instance Functor FromJSONKeyFunction where
467− fmap h (FromJSONKeyCoerce CoerceText) = FromJSONKeyText (h . coerce')
450+ fmap h (FromJSONKeyCoerce CoerceText) = FromJSONKeyText (h . coerce)
468451 fmap h (FromJSONKeyText f) = FromJSONKeyText (h . f)
469452 fmap h (FromJSONKeyTextParser f) = FromJSONKeyTextParser (fmap h . f)
470453 fmap h (FromJSONKeyValue f) = FromJSONKeyValue (fmap h . f)
@@ -478,9 +461,7 @@ instance Functor FromJSONKeyFunction where
478461--
479462-- On pre GHC 7.8 this is unconstrainted function.
480463fromJSONKeyCoerce ::
481−#if HAS_COERCIBLE
482464 Coercible Text a =>
483−#endif
484465 FromJSONKeyFunction a
485466fromJSONKeyCoerce = FromJSONKeyCoerce CoerceText
486467
@@ -488,29 +469,18 @@ fromJSONKeyCoerce = FromJSONKeyCoerce CoerceText
488469--
489470-- See note on 'fromJSONKeyCoerce'.
490471coerceFromJSONKeyFunction ::
491−#if HAS_COERCIBLE
492472 Coercible a b =>
493−#endif
494473 FromJSONKeyFunction a -> FromJSONKeyFunction b
495−#if HAS_COERCIBLE
496474coerceFromJSONKeyFunction = coerce
497−#else
498−coerceFromJSONKeyFunction (FromJSONKeyCoerce CoerceText) = FromJSONKeyCoerce CoerceText
499−coerceFromJSONKeyFunction (FromJSONKeyText f) = FromJSONKeyText (coerce' . f)
500−coerceFromJSONKeyFunction (FromJSONKeyTextParser f) = FromJSONKeyTextParser (fmap coerce' . f)
501−coerceFromJSONKeyFunction (FromJSONKeyValue f) = FromJSONKeyValue (fmap coerce' . f)
502−#endif
503475
504476{-# RULES
505477 "FromJSONKeyCoerce: fmap id" forall (x :: FromJSONKeyFunction a).
506478 fmap id x = x
507479 #-}
508−#if HAS_COERCIBLE
509480{-# RULES
510481 "FromJSONKeyCoerce: fmap coerce" forall x .
511482 fmap coerce x = coerceFromJSONKeyFunction x
512483 #-}
513−#endif
514484
515485-- | Same as 'fmap'. Provided for the consistency with 'ToJSONKeyFunction'.
516486mapFromJSONKeyFunction :: (a -> b) -> FromJSONKeyFunction a -> FromJSONKeyFunction b
@@ -797,13 +767,13 @@ withBoundedScientific' f v = withBoundedScientific_ id f v
797767-- | A variant of 'withBoundedScientific_' parameterized by a function to apply
798768-- to the 'Parser' in case of failure.
799769withBoundedScientific_ :: (Parser a -> Parser a) -> (Scientific -> Parser a) -> Value -> Parser a
800−withBoundedScientific_ whenFail f v@(Number scientific) =
801− if exponent > 1024
770+withBoundedScientific_ whenFail f (Number scientific) =
771+ if exp10 > 1024
802772 then whenFail (fail msg)
803773 else f scientific
804774 where
805− exponent = base10Exponent scientific
806− msg = "found a number with exponent " ++ show exponent ++ ", but it must not be greater than 1024"
775+ exp10 = base10Exponent scientific
776+ msg = "found a number with exponent " ++ show exp10 ++ ", but it must not be greater than 1024"
807777withBoundedScientific_ whenFail _ v =
808778 whenFail (typeMismatch "Number" v)
809779{-# INLINE withBoundedScientific_ #-}
@@ -823,7 +793,7 @@ withBool name _ v = prependContext name (typeMismatch "Boolean" v)
823793-- | Decode a nested JSON-encoded string.
824794withEmbeddedJSON :: String -> (Value -> Parser a) -> Value -> Parser a
825795withEmbeddedJSON _ innerParser (String txt) =
826− either fail innerParser $ eitherDecode (Compat.fromStrict $ T.encodeUtf8 txt)
796+ either fail innerParser $ eitherDecode (L.fromStrict $ T.encodeUtf8 txt)
827797 where
828798 eitherDecode = eitherFormatError . eitherDecodeWith jsonEOF ifromJSON
829799 eitherFormatError = either (Left . uncurry formatError) Right
@@ -1991,7 +1961,6 @@ instance FromJSON DotNetTime where
19911961-- primitive
19921962-------------------------------------------------------------------------------
19931963
1994−#if MIN_VERSION_base(4,7,0)
19951964instance FromJSON a => FromJSON (PM.Array a) where
19961965 -- note: we could do better than this if vector exposed the data
19971966 -- constructor in Data.Vector.
@@ -2009,7 +1978,6 @@ instance (PM.PrimUnlifted a,FromJSON a) => FromJSON (PM.UnliftedArray a) where
20091978 parseJSON = fmap Exts.fromList . parseJSON
20101979#endif
20111980#endif
2012−#endif
20131981
20141982-------------------------------------------------------------------------------
20151983-- time
Data/Aeson/Types/ToJSON.hs+3−41
@@ -8,15 +8,12 @@
88{-# LANGUAGE NoImplicitPrelude #-}
99{-# LANGUAGE OverloadedStrings #-}
1010{-# LANGUAGE PatternGuards #-}
11+{-# LANGUAGE PolyKinds #-}
1112{-# LANGUAGE RecordWildCards #-}
1213{-# LANGUAGE ScopedTypeVariables #-}
1314{-# LANGUAGE TypeOperators #-}
1415{-# LANGUAGE UndecidableInstances #-}
1516
16−#if __GLASGOW_HASKELL__ >= 706
17−{-# LANGUAGE PolyKinds #-}
18−#endif
19−
2017#include "overlapping-compat.h"
2118#include "incoherent-compat.h"
2219
@@ -144,14 +141,6 @@ import qualified Data.Primitive.UnliftedArray as PM
144141import qualified Data.Primitive.PrimArray as PM
145142#endif
146143
147−#if !(MIN_VERSION_bytestring(0,10,0))
148−import Foreign.ForeignPtr (withForeignPtr)
149−import Foreign.Marshal.Utils (copyBytes)
150−import Foreign.Ptr (plusPtr)
151−import qualified Data.ByteString.Internal as S
152−import qualified Data.ByteString.Lazy.Internal as L
153−#endif
154−
155144toJSONPair :: (a -> Value) -> (b -> Value) -> (a, b) -> Value
156145toJSONPair a b = liftToJSON2 a (listValue a) b (listValue b)
157146{-# INLINE toJSONPair #-}
@@ -515,7 +504,7 @@ toJSONKeyTextEnc e = ToJSONKeyText tot e
515504 -- TODO: dropAround is also used in stringEncoding, which is unfortunate atm
516505 tot = T.dropAround (== '"')
517506 . T.decodeLatin1
518− . lazyToStrictByteString
507+ . L.toStrict
519508 . E.encodingToLazyByteString
520509 . e
521510
@@ -1982,7 +1971,6 @@ formatMillis = take 3 . formatTime defaultTimeLocale "%q"
19821971-- primitive
19831972-------------------------------------------------------------------------------
19841973
1985−#if MIN_VERSION_base(4,7,0)
19861974instance ToJSON a => ToJSON (PM.Array a) where
19871975 -- note: we could do better than this if vector exposed the data
19881976 -- constructor in Data.Vector.
@@ -2004,7 +1992,6 @@ instance (PM.PrimUnlifted a,ToJSON a) => ToJSON (PM.UnliftedArray a) where
20041992 toEncoding = toEncoding . Exts.toList
20051993#endif
20061994#endif
2007−#endif
20081995
20091996-------------------------------------------------------------------------------
20101997-- time
@@ -2054,7 +2041,7 @@ stringEncoding :: Encoding' Text -> Value
20542041stringEncoding = String
20552042 . T.dropAround (== '"')
20562043 . T.decodeLatin1
2057− . lazyToStrictByteString
2044+ . L.toStrict
20582045 . E.encodingToLazyByteString
20592046{-# INLINE stringEncoding #-}
20602047
@@ -2861,31 +2848,6 @@ instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d, ToJSON e, ToJSON f, ToJSON g,
28612848 toEncoding = toEncoding2
28622849 {-# INLINE toEncoding #-}
28632850
2864−-------------------------------------------------------------------------------
2865−-- pre-bytestring-0.10 compatibility
2866−-------------------------------------------------------------------------------
2867−
2868−{-# INLINE lazyToStrictByteString #-}
2869−lazyToStrictByteString :: L.ByteString -> S.ByteString
2870−#if MIN_VERSION_bytestring(0,10,0)
2871−lazyToStrictByteString = L.toStrict
2872−#else
2873−lazyToStrictByteString = packChunks
2874−
2875−-- packChunks is taken from the blaze-builder package.
2876−
2877−-- | Pack the chunks of a lazy bytestring into a single strict bytestring.
2878−packChunks :: L.ByteString -> S.ByteString
2879−packChunks lbs =
2880− S.unsafeCreate (fromIntegral $ L.length lbs) (copyChunks lbs)
2881− where
2882− copyChunks L.Empty _pf = return ()
2883− copyChunks (L.Chunk (S.PS fpbuf o l) lbs') pf = do
2884− withForeignPtr fpbuf $ \pbuf ->
2885− copyBytes pf (pbuf `plusPtr` o) l
2886− copyChunks lbs' (pf `plusPtr` l)
2887−#endif
2888−
28892851--------------------------------------------------------------------------------
28902852
28912853-- | Wrap a list of pairs as an object.
aeson.cabal+4−10
@@ -88,7 +88,6 @@ library
8888 Data.Aeson.Encode
8989
9090 other-modules:
91− Data.Aeson.Compat
9291 Data.Aeson.Encoding.Builder
9392 Data.Aeson.Internal.Functions
9493 Data.Aeson.Parser.Unescape
@@ -103,11 +102,12 @@ library
103102
104103 -- GHC bundled libs
105104 build-depends:
106− base >= 4.5.0.0 && < 5,
107− containers >= 0.4.2.1 && < 0.7,
105+ base >= 4.7.0.0 && < 5,
106+ bytestring >= 0.10.4.0 && < 0.11,
107+ containers >= 0.5.5.1 && < 0.7,
108108 deepseq >= 1.3.0.0 && < 1.5,
109109 ghc-prim >= 0.2 && < 0.6,
110− template-haskell >= 2.7.0.0 && < 2.16,
110+ template-haskell >= 2.9.0.0 && < 2.16,
111111 text >= 1.2.3.0 && < 1.3,
112112 time >= 1.4 && < 1.10
113113
@@ -119,12 +119,6 @@ library
119119 base-compat >= 0.9.1 && < 0.12,
120120 time-compat >= 1.9.2.2 && < 1.10
121121
122− if flag(bytestring-builder)
123− build-depends: bytestring >= 0.9.2.1 && < 0.10.4,
124− bytestring-builder >= 0.10.4 && < 1
125− else
126− build-depends: bytestring >= 0.10.4 && < 0.11
127−
128122 if !impl(ghc >= 8.6)
129123 build-depends:
130124 contravariant >=1.4.1 && <1.6
attoparsec-iso8601/Data/Attoparsec/Time/Internal.hs−20
@@ -29,16 +29,8 @@ import Data.Time.Clock (diffTimeToPicoseconds)
2929
3030#endif
3131
32−#if MIN_VERSION_base(4,7,0)
33−
3432import Data.Fixed (Pico, Fixed(MkFixed))
3533
36−#else
37−
38−import Data.Fixed (Pico)
39−
40−#endif
41−
4234#if !MIN_VERSION_time(1,6,0)
4335
4436diffTimeToPicoseconds :: DiffTime -> Integer
@@ -46,24 +38,12 @@ diffTimeToPicoseconds = unsafeCoerce
4638
4739#endif
4840
49−#if MIN_VERSION_base(4,7,0)
50−
5141toPico :: Integer -> Pico
5242toPico = MkFixed
5343
5444fromPico :: Pico -> Integer
5545fromPico (MkFixed i) = i
5646
57−#else
58−
59−toPico :: Integer -> Pico
60−toPico = unsafeCoerce
61−
62−fromPico :: Pico -> Integer
63−fromPico = unsafeCoerce
64−
65−#endif
66−
6747-- | Like TimeOfDay, but using a fixed-width integer for seconds.
6848data TimeOfDay64 = TOD {-# UNPACK #-} !Int
6949 {-# UNPACK #-} !Int
attoparsec-iso8601/attoparsec-iso8601.cabal+1−1
@@ -36,7 +36,7 @@ library
3636 Data.Attoparsec.Time
3737 build-depends:
3838 attoparsec >= 0.13.0.1,
39− base >= 4.5 && < 5,
39+ base >= 4.7 && < 5,
4040 base-compat >= 0.9.1 && < 0.12,
4141 text >= 1.1.1.0,
4242 time >= 1.1.1.4
benchmarks/aeson-benchmarks.cabal−1
@@ -72,7 +72,6 @@ library
7272
7373 exposed-modules:
7474 Data.Aeson
75− Data.Aeson.Compat
7675 Data.Aeson.Encoding
7776 Data.Aeson.Encoding.Builder
7877 Data.Aeson.Encoding.Internal
cabal.project+1
@@ -2,3 +2,4 @@ with-compiler: ghc
22packages: .
33packages: attoparsec-iso8601
44-- packages: benchmarks
5+tests: true
tests/Encoders.hs−6
@@ -188,7 +188,6 @@ gSomeTypeToEncoding2ElemArray = genericToEncoding opts2ElemArray
188188gSomeTypeParseJSON2ElemArray :: Value -> Parser (SomeType Int)
189189gSomeTypeParseJSON2ElemArray = genericParseJSON opts2ElemArray
190190
191−#if __GLASGOW_HASKELL__ >= 706
192191gSomeTypeLiftToEncoding2ElemArray :: LiftToEncoding SomeType a
193192gSomeTypeLiftToEncoding2ElemArray = genericLiftToEncoding opts2ElemArray
194193
@@ -197,7 +196,6 @@ gSomeTypeLiftToJSON2ElemArray = genericLiftToJSON opts2ElemArray
197196
198197gSomeTypeLiftParseJSON2ElemArray :: LiftParseJSON SomeType a
199198gSomeTypeLiftParseJSON2ElemArray = genericLiftParseJSON opts2ElemArray
200−#endif
201199
202200
203201gSomeTypeToJSONTaggedObject :: SomeType Int -> Value
@@ -209,7 +207,6 @@ gSomeTypeToEncodingTaggedObject = genericToEncoding optsTaggedObject
209207gSomeTypeParseJSONTaggedObject :: Value -> Parser (SomeType Int)
210208gSomeTypeParseJSONTaggedObject = genericParseJSON optsTaggedObject
211209
212−#if __GLASGOW_HASKELL__ >= 706
213210gSomeTypeLiftToEncodingTaggedObject :: LiftToEncoding SomeType a
214211gSomeTypeLiftToEncodingTaggedObject = genericLiftToEncoding optsTaggedObject
215212
@@ -218,7 +215,6 @@ gSomeTypeLiftToJSONTaggedObject = genericLiftToJSON optsTaggedObject
218215
219216gSomeTypeLiftParseJSONTaggedObject :: LiftParseJSON SomeType a
220217gSomeTypeLiftParseJSONTaggedObject = genericLiftParseJSON optsTaggedObject
221−#endif
222218
223219
224220gSomeTypeToJSONObjectWithSingleField :: SomeType Int -> Value
@@ -230,7 +226,6 @@ gSomeTypeToEncodingObjectWithSingleField = genericToEncoding optsObjectWithSingl
230226gSomeTypeParseJSONObjectWithSingleField :: Value -> Parser (SomeType Int)
231227gSomeTypeParseJSONObjectWithSingleField = genericParseJSON optsObjectWithSingleField
232228
233−#if __GLASGOW_HASKELL__ >= 706
234229gSomeTypeLiftToEncodingObjectWithSingleField :: LiftToEncoding SomeType a
235230gSomeTypeLiftToEncodingObjectWithSingleField = genericLiftToEncoding optsObjectWithSingleField
236231
@@ -239,7 +234,6 @@ gSomeTypeLiftToJSONObjectWithSingleField = genericLiftToJSON optsObjectWithSingl
239234
240235gSomeTypeLiftParseJSONObjectWithSingleField :: LiftParseJSON SomeType a
241236gSomeTypeLiftParseJSONObjectWithSingleField = genericLiftParseJSON optsObjectWithSingleField
242−#endif
243237
244238
245239gSomeTypeToJSONOmitNothingFields :: SomeType Int -> Value
tests/Instances.hs−3
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
21{-# LANGUAGE FlexibleContexts #-}
32{-# LANGUAGE FlexibleInstances #-}
43{-# LANGUAGE NoImplicitPrelude #-}
@@ -25,9 +24,7 @@ import qualified Data.HashMap.Strict as HM
2524
2625import Data.Orphans ()
2726import Test.QuickCheck.Instances ()
28−#if MIN_VERSION_base(4,7,0)
2927import Data.Hashable.Time ()
30−#endif
3128
3229-- "System" types.
3330
tests/PropertyGeneric.hs−8
@@ -44,11 +44,9 @@ genericTests =
4444 , testProperty "TaggedObject" (toParseJSON gSomeTypeParseJSONTaggedObject gSomeTypeToJSONTaggedObject)
4545 , testProperty "ObjectWithSingleField" (toParseJSON gSomeTypeParseJSONObjectWithSingleField gSomeTypeToJSONObjectWithSingleField)
4646
47−#if __GLASGOW_HASKELL__ >= 706
4847 , testProperty "2ElemArray unary" (toParseJSON1 gSomeTypeLiftParseJSON2ElemArray gSomeTypeLiftToJSON2ElemArray)
4948 , testProperty "TaggedObject unary" (toParseJSON1 gSomeTypeLiftParseJSONTaggedObject gSomeTypeLiftToJSONTaggedObject)
5049 , testProperty "ObjectWithSingleField unary" (toParseJSON1 gSomeTypeLiftParseJSONObjectWithSingleField gSomeTypeLiftToJSONObjectWithSingleField)
51−#endif
5250 ]
5351 ]
5452 , testGroup "OneConstructor" [
@@ -85,30 +83,24 @@ genericTests =
8583
8684 , testProperty "SomeType2ElemArray" $
8785 gSomeTypeToJSON2ElemArray `sameAs` gSomeTypeToEncoding2ElemArray
88−#if __GLASGOW_HASKELL__ >= 706
8986 , testProperty "SomeType2ElemArray unary" $
9087 gSomeTypeLiftToJSON2ElemArray `sameAs1` gSomeTypeLiftToEncoding2ElemArray
9188 , testProperty "SomeType2ElemArray unary agree" $
9289 gSomeTypeToEncoding2ElemArray `sameAs1Agree` gSomeTypeLiftToEncoding2ElemArray
93−#endif
9490
9591 , testProperty "SomeTypeTaggedObject" $
9692 gSomeTypeToJSONTaggedObject `sameAs` gSomeTypeToEncodingTaggedObject
97−#if __GLASGOW_HASKELL__ >= 706
9893 , testProperty "SomeTypeTaggedObject unary" $
9994 gSomeTypeLiftToJSONTaggedObject `sameAs1` gSomeTypeLiftToEncodingTaggedObject
10095 , testProperty "SomeTypeTaggedObject unary agree" $
10196 gSomeTypeToEncodingTaggedObject `sameAs1Agree` gSomeTypeLiftToEncodingTaggedObject
102−#endif
10397
10498 , testProperty "SomeTypeObjectWithSingleField" $
10599 gSomeTypeToJSONObjectWithSingleField `sameAs` gSomeTypeToEncodingObjectWithSingleField
106−#if __GLASGOW_HASKELL__ >= 706
107100 , testProperty "SomeTypeObjectWithSingleField unary" $
108101 gSomeTypeLiftToJSONObjectWithSingleField `sameAs1` gSomeTypeLiftToEncodingObjectWithSingleField
109102 , testProperty "SomeTypeObjectWithSingleField unary agree" $
110103 gSomeTypeToEncodingObjectWithSingleField `sameAs1Agree` gSomeTypeLiftToEncodingObjectWithSingleField
111−#endif
112104
113105 , testProperty "SomeTypeOmitNothingFields" $
114106 gSomeTypeToJSONOmitNothingFields `sameAs` gSomeTypeToEncodingOmitNothingFields
tests/PropertyKeys.hs−3
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
21{-# LANGUAGE NoImplicitPrelude #-}
32
43module PropertyKeys ( keysTests ) where
@@ -31,12 +30,10 @@ keysTests =
3130 , testProperty "Natural" $ roundTripKey (undefined :: Natural)
3231 , testProperty "Float" $ roundTripKey (undefined :: Float)
3332 , testProperty "Double" $ roundTripKey (undefined :: Double)
34−#if MIN_VERSION_base(4,7,0)
3533 , testProperty "Day" $ roundTripKey (undefined :: Day)
3634 , testProperty "LocalTime" $ roundTripKey (undefined :: LocalTime)
3735 , testProperty "TimeOfDay" $ roundTripKey (undefined :: TimeOfDay)
3836 , testProperty "UTCTime" $ roundTripKey (undefined :: UTCTime)
39−#endif
4037 , testProperty "Version" $ roundTripKey (undefined :: Version)
4138 , testProperty "Lazy Text" $ roundTripKey (undefined :: LT.Text)
4239 , testProperty "UUID" $ roundTripKey UUID.nil
tests/SerializationFormatSpec.hs−4
@@ -3,9 +3,7 @@
33{-# LANGUAGE GADTs #-}
44{-# LANGUAGE NoImplicitPrelude #-}
55{-# LANGUAGE OverloadedStrings #-}
6−#if __GLASGOW_HASKELL__ >= 708
76{-# LANGUAGE DataKinds #-}
8−#endif
97
108------------------------------------------------------------------------------
119-- These tests assert that the JSON serialization doesn't change by accident.
@@ -77,10 +75,8 @@ jsonExamples =
7775 , example "Just" "1" (Just 1 :: Maybe Int)
7876 , example "Proxy Int" "null" (Proxy :: Proxy Int)
7977 , example "Tagged Char Int" "1" (Tagged 1 :: Tagged Char Int)
80−#if __GLASGOW_HASKELL__ >= 708
8178 -- Test Tagged instance is polykinded
8279 , example "Tagged 123 Int" "1" (Tagged 1 :: Tagged 123 Int)
83−#endif
8480 , example "Const Char Int" "\"c\"" (Const 'c' :: Const Char Int)
8581 , example "Tuple" "[1,2]" ((1, 2) :: (Int, Int))
8682 , example "NonEmpty" "[1,2,3]" (1 :| [2, 3] :: NonEmpty Int)
tests/Types.hs−2
@@ -119,9 +119,7 @@ deriving instance Generic (Sum4 a b c d)
119119deriving instance Generic (Approx a)
120120deriving instance Generic Nullary
121121deriving instance Generic (SomeType a)
122−#if __GLASGOW_HASKELL__ >= 706
123122deriving instance Generic1 SomeType
124−#endif
125123deriving instance Generic OptionField
126124deriving instance Generic EitherTextInt
127125