aristidb / aws

Amazon Web Services for Haskell
BSD 3-Clause "New" or "Revised" License
239 stars 108 forks source link

Build error with aeson 2.2 #288

Closed Vekhir closed 9 months ago

Vekhir commented 1 year ago

Hi, when building with aeson 2.2, I get the following error:

[32 of 91] Compiling Aws.DynamoDb.Core ( Aws/DynamoDb/Core.hs, dist/build/Aws/DynamoDb/Core.dyn_o )

Aws/DynamoDb/Core.hs:907:63: error:
    Not in scope: ‘A.json'’
    Neither ‘Data.Aeson’ nor ‘Data.Aeson.Types’ exports ‘json'’.
    |
907 |     val <- runConduit $ HTTP.responseBody resp .| sinkParser (A.json' <* AttoB.endOfInput)
    |                                                               ^^^^^^^

It seems that the .json' functionality got moved into attoparsec-aeson: https://hackage.haskell.org/package/attoparsec-aeson-2.2.0.0/docs/Data-Aeson-Parser.html

As such, it is probably necessary to add attoparsec-aeson>=2.1.0.0 to aws.cabal.

bgamari commented 1 year ago

The following patch was sufficient for me to build against aeson-2.2.

diff --git a/Aws/DynamoDb/Core.hs b/Aws/DynamoDb/Core.hs
index b9a6cc4..b542ef3 100644
--- a/Aws/DynamoDb/Core.hs
+++ b/Aws/DynamoDb/Core.hs
@@ -130,6 +130,7 @@ import           Data.Aeson
 import qualified Data.Aeson                   as A
 import qualified Data.Aeson.Key               as AK
 import qualified Data.Aeson.KeyMap            as KM
+import           Data.Aeson.Parser            as A (json')
 import           Data.Aeson.Types             (Pair, parseEither)
 import qualified Data.Aeson.Types             as A
 import qualified Data.Attoparsec.ByteString   as AttoB (endOfInput)
@@ -1164,7 +1165,7 @@ data QuerySelect
 instance Default QuerySelect where def = SelectAll

 -------------------------------------------------------------------------------
-querySelectJson :: KeyValue t => QuerySelect -> [t]
+querySelectJson :: KeyValue A.Value t => QuerySelect -> [t]
 querySelectJson (SelectSpecific as) =
     [ "Select" .= String "SPECIFIC_ATTRIBUTES"
     , "AttributesToGet" .= as]
diff --git a/aws.cabal b/aws.cabal
index 67adbeb..64add1e 100644
--- a/aws.cabal
+++ b/aws.cabal
@@ -129,6 +129,7 @@ Library

   Build-depends:
                        aeson                >= 2.0.0.0,
+                       attoparsec-aeson     >= 2.1.0.0,
                        attoparsec           >= 0.11    && < 0.15,
                        base                 >= 4.9     && < 5,
                        base16-bytestring    >= 0.1     && < 1.1,
joeyh commented 9 months ago

@bgamari that fails to build here (ghc 9.4.7)

Aws/DynamoDb/Core.hs:1168:20: error: • Expected kind ‘* -> Constraint’, but ‘KeyValue Value’ has kind ‘Constraint’ • In the type signature: querySelectJson :: KeyValue Value t => QuerySelect -> [t] | 1168 | querySelectJson :: KeyValue A.Value t => QuerySelect -> [t] | ^^^^^^^^^^^^^^^^^^

Keeping the original type signature of querySelectJson, it builds for me. What motivated the A.Value change?

joeyh commented 9 months ago

Oh I see, KeyValue has changed in aeson-2.2. So this will also need to bump the aeson bounds.