Skip to content

Commit 07a0a71

Browse files
committed
Tentatively migrate to GHC 9.2
This commit allows `aeson` to build and run on GHC 9.2.0.20210422, including tests. This is intended to help with migration to GHC 9.2, once it is released. Changes: - Remove tests for `Semigroup.Option` when base >= 4.16.0
1 parent c64f88f commit 07a0a71

9 files changed

+138
-5
lines changed

aeson.cabal

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ library
9292
bytestring >= 0.10.4.0 && < 0.12,
9393
containers >= 0.5.5.1 && < 0.7,
9494
deepseq >= 1.3.0.0 && < 1.5,
95-
ghc-prim >= 0.2 && < 0.8,
96-
template-haskell >= 2.9.0.0 && < 2.18,
95+
ghc-prim >= 0.2 && < 0.9,
96+
template-haskell >= 2.9.0.0 && < 2.19,
9797
text >= 1.2.3.0 && < 1.3,
9898
time >= 1.4 && < 1.12
9999

@@ -102,7 +102,7 @@ library
102102

103103
-- Compat
104104
build-depends:
105-
base-compat-batteries >= 0.10.0 && < 0.12,
105+
base-compat-batteries >= 0.10.0 && < 0.13,
106106
time-compat >= 1.9.6 && < 1.10
107107

108108
if !impl(ghc >= 8.6)
@@ -136,7 +136,7 @@ library
136136
these >= 1.1 && < 1.2,
137137
unordered-containers >= 0.2.10.0 && < 0.3,
138138
uuid-types >= 1.0.3 && < 1.1,
139-
vector >= 0.12.0.1 && < 0.13
139+
vector >= 0.12.0.1 && < 0.14
140140

141141
ghc-options: -Wall
142142

attoparsec-iso8601/attoparsec-iso8601.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ library
3939
build-depends:
4040
attoparsec >= 0.13.0.1 && < 0.15.0.0,
4141
base >= 4.7 && < 5,
42-
base-compat-batteries >= 0.10.0 && < 0.12,
42+
base-compat-batteries >= 0.10.0 && < 0.13,
4343
time-compat >= 1.9.4 && < 1.10,
4444
text >= 1.1.1.0 && < 1.3.0.0,
4545
time >= 1.1.1.4 && < 1.12

cabal.project

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,106 @@ packages: attoparsec-iso8601
44
packages: examples
55
tests: true
66
-- constraints: aeson +cffi
7+
8+
-- TODO: Remove the below vendored packages when they have migrated to GHC 9.2
9+
10+
source-repository-package
11+
type: git
12+
location: https://github.com/awjchen/qc-instances
13+
tag: b90f1211f0a1e022bf74336210ede3b875658c9e
14+
15+
source-repository-package
16+
type: git
17+
location: https://github.com/haskell/primitive
18+
tag: 1704f59d91ef964f83c120af4974251d50c2eb68
19+
20+
source-repository-package
21+
type: git
22+
location: https://github.com/awjchen/vector
23+
tag: fb6f584abff163a361563a98a7760c563f7a6832
24+
subdir: vector
25+
26+
source-repository-package
27+
type: git
28+
location: https://github.com/awjchen/time-compat
29+
tag: dc10e814fcbdd85b7dd8da64df7ae954c580a7ed
30+
31+
source-repository-package
32+
type: git
33+
location: https://github.com/awjchen/these
34+
tag: 1d03307d2b8ca1c03631df7e9d9651b25907ede2
35+
subdir: these
36+
37+
source-repository-package
38+
type: git
39+
location: https://github.com/awjchen/assoc
40+
tag: d43d2eccc31a37475898c56e7273f9ebcc182786
41+
42+
source-repository-package
43+
type: git
44+
location: https://github.com/awjchen/indexed-traversable
45+
tag: ea22848a529e1225a0590ac3c73ea06a071
46+
subdir: indexed-traversable
47+
48+
source-repository-package
49+
type: git
50+
location: https://github.com/haskellari/splitmix
51+
tag: 4606188a437e6f6478fed2a20cadd716589f25ea
52+
53+
source-repository-package
54+
type: git
55+
location: https://github.com/awjchen/integer-logarithms
56+
tag: 7c774f6024151e284b82dc1ad14f5f454978cdd3
57+
58+
source-repository-package
59+
type: git
60+
location: https://github.com/awjchen/hashable
61+
tag: 1bd4032cf83dab6640352bb9d31e1390e634a0b6
62+
63+
source-repository-package
64+
type: git
65+
location: https://github.com/awjchen/data-fix
66+
tag: fb619187db1b6a358dbe1a62c45b07c904da72d3
67+
68+
source-repository-package
69+
type: git
70+
location: https://github.com/haskell/primitive
71+
tag: 1704f59d91ef964f83c120af4974251d50c2eb68
72+
73+
source-repository-package
74+
type: git
75+
location: https://github.com/awjchen/vector
76+
tag: fb6f584abff163a361563a98a7760c563f7a6832
77+
subdir: vector
78+
79+
source-repository-package
80+
type: git
81+
location: https://github.com/haskell/random
82+
tag: 6d8b9b5f09bfd726662035c2a9687c1c23a3ebbc
83+
84+
source-repository-package
85+
type: git
86+
location: https://github.com/awjchen/scientific
87+
tag: e76cc2299175ec922d67e555d2d112ad29142e5f
88+
89+
source-repository-package
90+
type: git
91+
location: https://github.com/awjchen/attoparsec
92+
tag: 6c60dd7fd67d21903005b3db288f6c6da760507e
93+
94+
source-repository-package
95+
type: git
96+
location: https://github.com/awjchen/base16-bytestring
97+
tag: 18dd221ca3eebb0ecd46777c6c556b6fd58a3b45
98+
99+
source-repository-package
100+
type: git
101+
location: https://github.com/haskell-compat/base-compat
102+
tag: 847aa35c4142f529525ffc645cd035ddb23ce8ee
103+
subdir: base-compat
104+
105+
source-repository-package
106+
type: git
107+
location: https://github.com/haskell-compat/base-compat
108+
tag: 847aa35c4142f529525ffc645cd035ddb23ce8ee
109+
subdir: base-compat-batteries

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 #-}
@@ -153,8 +154,10 @@ instance Arbitrary EitherTextInt where
153154
instance Arbitrary (GADT String) where
154155
arbitrary = GADT <$> arbitrary
155156

157+
#if !MIN_VERSION_base(4,16,0)
156158
instance Arbitrary OptionField where
157159
arbitrary = OptionField <$> arbitrary
160+
#endif
158161

159162

160163
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
@@ -212,8 +212,10 @@ jsonExamples =
212212
, example "Semigroup.First Int" "2" (pure 2 :: Semigroup.First Int)
213213
, example "Semigroup.Last Int" "2" (pure 2 :: Semigroup.Last Int)
214214
, example "Semigroup.WrappedMonoid Int" "2" (Semigroup.WrapMonoid 2 :: Semigroup.WrappedMonoid Int)
215+
#if !MIN_VERSION_base(4,16,0)
215216
, example "Semigroup.Option Just" "2" (pure 2 :: Semigroup.Option Int)
216217
, example "Semigroup.Option Nothing" "null" (Semigroup.Option (Nothing :: Maybe Bool))
218+
#endif
217219

218220
-- time 1.9
219221
, 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)