http-client icon indicating copy to clipboard operation
http-client copied to clipboard

Not compatible with `aeson > 2.0.0.0`

Open bogdan-manole opened this issue 2 years ago • 1 comments

There is no more Data.Aeson.Parser module starting with version aeson-2.0.0.0 and no json' either. When the library is built with aeson flag and aeson > 2.0.0.0 the building will fail with:

 > Network/HTTP/Simple.hs:106:1: error:
 >     Could not find module ‘Data.Aeson.Parser’
 >     Use -v (or `:set -v` in ghci) to see a list of the files searched for.
 >     |
 > 106 | import Data.Aeson.Parser (json')

https://github.com/snoyberg/http-client/blob/f4f76f4fd72f227074d8635c244ea0b3b61c7163/http-conduit/Network/HTTP/Simple.hs#L106C1-L106C1

UPDATE: I see there is the dependency of attoparsec-aeson which has that implementation of Data.Aeson.Parser module, though I don't know why is not taken into consideration in my build set

bogdan-manole avatar Oct 15 '23 22:10 bogdan-manole

It seems I used an older/intermediate version from hackage (>= 2.2.0 && <2.3.7) . Now I referenced it directly from github and it works. Anyway, I guess these newer versions won't work anymore with aeson <2.x.x (though the dependency constraint of the aeson specifies that it is allowed ) since there will be an ambiguity on which Data.Aeson.Parsec to be used (from aeson or attoparsec-aeson).

maybe PackageImports extension should be used instead

{-# LANGUAGE PackageImports      #-}
.....
#ifdef VERSION_aeson
import Data.Aeson (FromJSON (..), Value)
import "attoparsec-aeson"Data.Aeson.Parser (json')
.....
#endif

bogdan-manole avatar Oct 16 '23 09:10 bogdan-manole