Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for Aeson-2.2.3 #252

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions proto3-suite.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ library

other-modules: Turtle.Compat

build-depends: aeson >= 1.1.1.0 && < 2.3,
build-depends: aeson >= 1.1.1.0,
aeson-pretty,
attoparsec >= 0.13.0.1,
attoparsec-aeson,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is attoparsec-aeson used for? If we absolutely must depend on attoparsec-aeson then can we have bounds added?

base >=4.15 && <5.0,
base64-bytestring >= 1.0.0.1 && < 1.3,
binary >=0.8.3,
Expand Down Expand Up @@ -190,8 +191,9 @@ test-suite tests
Test.Proto.Parse.Option

build-depends:
aeson >= 1.1.1.0 && < 2.2
aeson >= 1.1.1.0
, attoparsec >= 0.13.0.1
, attoparsec-aeson
, base >=4.15 && <5.0
, base64-bytestring >= 1.0.0.1 && < 1.3
, bytestring >=0.10.6.0 && <0.13
Expand Down
18 changes: 15 additions & 3 deletions src/Proto3/Suite/JSONPB/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,23 @@ instance A.ToJSONKey (Proto3.Suite.Types.String TS.ShortText) where
#endif

instance (A.ToJSONKey k, ToJSONPB k, ToJSONPB v) => ToJSONPB (M.Map k v) where
toJSONPB m opts = A.liftToJSON @(M.Map k) (`toJSONPB` opts) (A.Array . V.fromList . map (`toJSONPB` opts)) m
toEncodingPB m opts = A.liftToEncoding @(M.Map k) (`toEncodingPB` opts) (E.list (`toEncodingPB` opts)) m
toJSONPB m opts = A.liftToJSON @(M.Map k)
#if MIN_VERSION_aeson(2,2,0)
(const False) -- Unless and until we test for the protobuf default value.
#endif
(`toJSONPB` opts) (A.Array . V.fromList . map (`toJSONPB` opts)) m
toEncodingPB m opts = A.liftToEncoding @(M.Map k)
#if MIN_VERSION_aeson(2,2,0)
(const False) -- Unless and until we test for the protobuf default value.
#endif
(`toEncodingPB` opts) (E.list (`toEncodingPB` opts)) m

instance (Ord k, A.FromJSONKey k, FromJSONPB k, FromJSONPB v) => FromJSONPB (M.Map k v) where
parseJSONPB = A.liftParseJSON @(M.Map k) parseJSONPB parseList
parseJSONPB = A.liftParseJSON @(M.Map k)
#if MIN_VERSION_aeson(2,2,0)
Nothing -- Unless and until we decide to use the protobuf default value.
#endif
parseJSONPB parseList
where
parseList (A.Array a) = traverse parseJSONPB (V.toList a)
parseList v = A.typeMismatch "not a list" v
12 changes: 9 additions & 3 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resolver:
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/0.yaml
resolver: nightly-2024-07-12
# url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/0.yaml

allow-newer: true

Expand All @@ -8,9 +8,15 @@ packages:

extra-deps:
- github: awakesecurity/proto3-wire
commit: 9b1c178f8a23a5f03237cb77cce403bc386da523
commit: 2d48ee3446858f08a8c75130c90d770c377569bd

nix:
packages:
- zlib.dev
- zlib.out


flags:
proto3-suite:
large-records: False
dhall: False
23 changes: 11 additions & 12 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@

packages:
- completed:
size: 45006
url: https://github.com/awakesecurity/proto3-wire/archive/9b1c178f8a23a5f03237cb77cce403bc386da523.tar.gz
name: proto3-wire
version: 1.2.2
sha256: df812fdfe6c7df641d310c6273c16de4fda8f4d61635f084e24937ca0b91944c
pantry-tree:
size: 1325
sha256: bf3471cb92d5c273bf1163594380e836b48917a076b08827286a32f3d2320dee
sha256: 435441c5b8a677353e3c6566f3e6e7d9c1947ff75ade51ce1bc8d66e4ae329eb
size: 2648
sha256: 5a695d66823f50b74dc0a1d8a3da52391b2f7d75c8964fa6dff69254deef24ce
size: 54131
url: https://github.com/awakesecurity/proto3-wire/archive/2d48ee3446858f08a8c75130c90d770c377569bd.tar.gz
version: 1.4.3
original:
url: https://github.com/awakesecurity/proto3-wire/archive/9b1c178f8a23a5f03237cb77cce403bc386da523.tar.gz
url: https://github.com/awakesecurity/proto3-wire/archive/2d48ee3446858f08a8c75130c90d770c377569bd.tar.gz
snapshots:
- completed:
size: 585393
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/0.yaml
sha256: c632012da648385b9fa3c29f4e0afd56ead299f1c5528ee789058be410e883c0
original:
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/0.yaml
sha256: f594be174cb2b7ca5a2e22adc85de4838e45d2e590791417ad04f9017b9215bf
size: 654063
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2024/7/12.yaml
original: nightly-2024-07-12
Loading