Skip to content

Commit 48739c7

Browse files
committed
Migrate to GHC 9.2
This commit allows `aeson` to build and run on GHC 9.2.1, including tests. Changes: - Remove tests for `Semigroup.Option` when base >= 4.16.0 - Bump version bounds for `ghc-prim` and `template-haskell`
1 parent 8aee2be commit 48739c7

7 files changed

+32
-2
lines changed

aeson.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ library
103103
, bytestring >=0.10.8.1 && <0.12
104104
, containers >=0.5.7.1 && <0.7
105105
, deepseq >=1.4.2.0 && <1.5
106-
, ghc-prim >=0.5.0.0 && <0.8
107-
, template-haskell >=2.11.0.0 && <2.18
106+
, ghc-prim >=0.5.0.0 && <0.9
107+
, template-haskell >=2.11.0.0 && <2.19
108108
, text >=1.2.3.0 && <1.3
109109
, time >=1.6.0.1 && <1.12
110110

tests/Encoders.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ gFooParseJSONRejectUnknownFieldsTagged = genericParseJSON optsRejectUnknownField
272272
-- Option fields
273273
--------------------------------------------------------------------------------
274274

275+
#if !MIN_VERSION_base(4,16,0)
275276
thOptionFieldToJSON :: OptionField -> Value
276277
thOptionFieldToJSON = $(mkToJSON optsOptionField 'OptionField)
277278

@@ -289,6 +290,7 @@ gOptionFieldToEncoding = genericToEncoding optsOptionField
289290

290291
gOptionFieldParseJSON :: Value -> Parser OptionField
291292
gOptionFieldParseJSON = genericParseJSON optsOptionField
293+
#endif
292294

293295
thMaybeFieldToJSON :: MaybeField -> Value
294296
thMaybeFieldToJSON = $(mkToJSON optsOptionField 'MaybeField)

tests/Instances.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE FlexibleContexts #-}
23
{-# LANGUAGE FlexibleInstances #-}
34
{-# LANGUAGE NoImplicitPrelude #-}
@@ -156,8 +157,10 @@ instance Arbitrary EitherTextInt where
156157
instance Arbitrary (GADT String) where
157158
arbitrary = GADT <$> arbitrary
158159

160+
#if !MIN_VERSION_base(4,16,0)
159161
instance Arbitrary OptionField where
160162
arbitrary = OptionField <$> arbitrary
163+
#endif
161164

162165

163166
instance ApproxEq Char where

tests/PropertyGeneric.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ module PropertyGeneric ( genericTests ) where
55

66
import Prelude.Compat
77

8+
#if !MIN_VERSION_base(4,16,0)
89
import Data.Semigroup (Option(..))
10+
#endif
911
import Encoders
1012
import Instances ()
1113
import Test.Tasty (TestTree, testGroup)
1214
import Test.Tasty.QuickCheck (testProperty)
15+
#if !MIN_VERSION_base(4,16,0)
1316
import Test.QuickCheck ( (===) )
1417
import Types
18+
#endif
1519
import PropUtils
1620

1721

@@ -57,11 +61,13 @@ genericTests =
5761
, testProperty "Tagged" (toParseJSON gOneConstructorParseJSONTagged gOneConstructorToJSONTagged)
5862
]
5963
]
64+
#if !MIN_VERSION_base(4,16,0)
6065
, testGroup "OptionField" [
6166
testProperty "like Maybe" $
6267
\x -> gOptionFieldToJSON (OptionField (Option x)) === thMaybeFieldToJSON (MaybeField x)
6368
, testProperty "roundTrip" (toParseJSON gOptionFieldParseJSON gOptionFieldToJSON)
6469
]
70+
#endif
6571
]
6672
, testGroup "toEncoding" [
6773
testProperty "NullaryString" $
@@ -110,7 +116,9 @@ genericTests =
110116
, testProperty "OneConstructorTagged" $
111117
gOneConstructorToJSONTagged `sameAs` gOneConstructorToEncodingTagged
112118

119+
#if !MIN_VERSION_base(4,16,0)
113120
, testProperty "OptionField" $
114121
gOptionFieldToJSON `sameAs` gOptionFieldToEncoding
122+
#endif
115123
]
116124
]

tests/PropertyTH.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE NoImplicitPrelude #-}
23

34
module PropertyTH ( templateHaskellTests ) where
45

56
import Prelude.Compat
67

8+
#if !MIN_VERSION_base(4,16,0)
79
import Data.Semigroup (Option(..))
10+
#endif
811
import Encoders
912
import Instances ()
1013
import Test.Tasty (TestTree, testGroup)
1114
import Test.Tasty.QuickCheck (testProperty)
15+
#if !MIN_VERSION_base(4,16,0)
1216
import Test.QuickCheck ( (===) )
1317
import Types
18+
#endif
1419
import PropUtils
1520

1621

@@ -74,11 +79,13 @@ templateHaskellTests =
7479
, testProperty "Tagged" (toParseJSON thOneConstructorParseJSONTagged thOneConstructorToJSONTagged)
7580
]
7681
]
82+
#if !MIN_VERSION_base(4,16,0)
7783
, testGroup "OptionField" [
7884
testProperty "like Maybe" $
7985
\x -> thOptionFieldToJSON (OptionField (Option x)) === thMaybeFieldToJSON (MaybeField x)
8086
, testProperty "roundTrip" (toParseJSON thOptionFieldParseJSON thOptionFieldToJSON)
8187
]
88+
#endif
8289
]
8390
, testGroup "toEncoding" [
8491
testProperty "NullaryString" $
@@ -124,7 +131,9 @@ templateHaskellTests =
124131
, testProperty "OneConstructorTagged" $
125132
thOneConstructorToJSONTagged `sameAs` thOneConstructorToEncodingTagged
126133

134+
#if !MIN_VERSION_base(4,16,0)
127135
, testProperty "OptionField" $
128136
thOptionFieldToJSON `sameAs` thOptionFieldToEncoding
137+
#endif
129138
]
130139
]

tests/SerializationFormatSpec.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,10 @@ jsonExamples =
214214
, example "Semigroup.First Int" "2" (pure 2 :: Semigroup.First Int)
215215
, example "Semigroup.Last Int" "2" (pure 2 :: Semigroup.Last Int)
216216
, example "Semigroup.WrappedMonoid Int" "2" (Semigroup.WrapMonoid 2 :: Semigroup.WrappedMonoid Int)
217+
#if !MIN_VERSION_base(4,16,0)
217218
, example "Semigroup.Option Just" "2" (pure 2 :: Semigroup.Option Int)
218219
, example "Semigroup.Option Nothing" "null" (Semigroup.Option (Nothing :: Maybe Bool))
220+
#endif
219221

220222
-- time 1.9
221223
, example "SystemTime" "123.123456789" (MkSystemTime 123 123456789)

tests/Types.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import Data.Data
1818
import Data.Functor.Compose (Compose (..))
1919
import Data.Functor.Identity (Identity (..))
2020
import Data.Hashable (Hashable (..))
21+
#if !MIN_VERSION_base(4,16,0)
2122
import Data.Semigroup (Option)
23+
#endif
2224
import Data.Text
2325
import Data.Time (Day (..), fromGregorian)
2426
import GHC.Generics
@@ -107,8 +109,10 @@ deriving instance Eq (GADT a)
107109
deriving instance Show (GADT a)
108110

109111
newtype MaybeField = MaybeField { maybeField :: Maybe Int }
112+
#if !MIN_VERSION_base(4,16,0)
110113
newtype OptionField = OptionField { optionField :: Option Int }
111114
deriving (Eq, Show)
115+
#endif
112116

113117
deriving instance Generic Foo
114118
deriving instance Generic UFoo
@@ -120,7 +124,9 @@ deriving instance Generic (Approx a)
120124
deriving instance Generic Nullary
121125
deriving instance Generic (SomeType a)
122126
deriving instance Generic1 SomeType
127+
#if !MIN_VERSION_base(4,16,0)
123128
deriving instance Generic OptionField
129+
#endif
124130
deriving instance Generic EitherTextInt
125131

126132
failure :: Show a => String -> String -> a -> Property

0 commit comments

Comments
 (0)