aristidb / aws

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

Build errors with aeson-2 #275

Closed sjakobi closed 2 years ago

sjakobi commented 2 years ago

When I build aws-0.22 with aeson-2.0.1.0, I get the following errors:

Aws/DynamoDb/Core.hs:539:18: error:
    • Couldn't match type ‘Data.Aeson.KeyMap.KeyMap Value’
                     with ‘HM.HashMap k0 v0’
      Expected type: HM.HashMap k0 v0
        Actual type: Object
    • In the first argument of ‘HM.union’, namely ‘p1’
      In the first argument of ‘Object’, namely ‘(p1 `HM.union` p2)’
      In the expression: Object (p1 `HM.union` p2)
    |
539 |       in Object (p1 `HM.union` p2)
    |                  ^^

Aws/DynamoDb/Core.hs:539:18: error:
    • Couldn't match type ‘HM.HashMap k0 v0’
                     with ‘Data.Aeson.KeyMap.KeyMap Value’
      Expected type: Object
        Actual type: HM.HashMap k0 v0
    • In the first argument of ‘Object’, namely ‘(p1 `HM.union` p2)’
      In the expression: Object (p1 `HM.union` p2)
      In the expression:
        let
          Object p1 = toJSON h
          Object p2 = toJSON r
        in Object (p1 `HM.union` p2)
    |
539 |       in Object (p1 `HM.union` p2)
    |                  ^^^^^^^^^^^^^^^^

Aws/DynamoDb/Core.hs:539:32: error:
    • Couldn't match type ‘Data.Aeson.KeyMap.KeyMap Value’
                     with ‘HM.HashMap k0 v0’
      Expected type: HM.HashMap k0 v0
        Actual type: Object
    • In the second argument of ‘HM.union’, namely ‘p2’
      In the first argument of ‘Object’, namely ‘(p1 `HM.union` p2)’
      In the expression: Object (p1 `HM.union` p2)
    |
539 |       in Object (p1 `HM.union` p2)
    |                                ^^

Aws/DynamoDb/Core.hs:664:55: error:
    • Couldn't match type ‘Data.Aeson.KeyMap.KeyMap Value’
                     with ‘HM.HashMap T.Text Value’
      Expected type: HM.HashMap T.Text Value
        Actual type: Object
    • In the first argument of ‘HM.toList’, namely ‘v’
      In the second argument of ‘($)’, namely ‘HM.toList v’
      In the expression: mapM conv $ HM.toList v
    |
664 | parseAttributeJson (Object v) = mapM conv $ HM.toList v
    |                                                       ^

Aws/DynamoDb/Core.hs:677:34: error:
    • Couldn't match expected type ‘Key’ with actual type ‘T.Text’
    • In the first argument of ‘(.=)’, namely ‘nm’
      In the expression: nm .= v
      In an equation for ‘attributeJson’:
          attributeJson (Attribute nm v) = nm .= v
    |
677 | attributeJson (Attribute nm v) = nm .= v
    |                                  ^^

Aws/DynamoDb/Core.hs:965:17: error:
    • Couldn't match expected type ‘Key’ with actual type ‘T.Text’
    • In the first argument of ‘(.=)’, namely ‘key’
      In the expression: key .= object (map conditionJson es)
      In the expression: [key .= object (map conditionJson es)]
    |
965 |           else [key .= object (map conditionJson es)]
    |                 ^^^

Aws/DynamoDb/Core.hs:1049:31: error:
    • Couldn't match expected type ‘Key’ with actual type ‘T.Text’
    • In the first argument of ‘(.=)’, namely ‘condAttr’
      In the expression: condAttr .= condOp
      In an equation for ‘conditionJson’:
          conditionJson Condition {..} = condAttr .= condOp
     |
1049 | conditionJson Condition{..} = condAttr .= condOp
     |                               ^^^^^^^^
sjakobi commented 2 years ago

As a Hackage trustee, I have created some Hackage revisions that should prevent users from running into the errors above, e.g. https://hackage.haskell.org/package/aws-0.22/revisions/.

joeyh commented 2 years ago

For what it's worth, the revision @sjakobi added on aws-0.21.1 broke compilation on OSX with ghc 8.6.3. The build error looked like this:

/Users/runner/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.3: cannot execute binary file

My guess is the cabal file modification may not be parsed properly by that old toolchain, but that is only a guess. We got around the problem by upgrading ghc.

sjakobi commented 2 years ago

Thanks for the feedback @joeyh!

I have tried to reproduce the issue on my local Ubuntu machine with cabal-install-2.4.1.0 and ghc-8.6.5, but got a clean build. I can't easily investigate the issue further because I don't have an OSX machine.

If anyone else discovers that another Hackage revision would fix the issue, I'd happily apply it.