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

Make honest Aeson Eq instance #7

Open
bladyjoker opened this issue Jun 8, 2022 · 0 comments
Open

Make honest Aeson Eq instance #7

bladyjoker opened this issue Jun 8, 2022 · 0 comments

Comments

@bladyjoker
Copy link
Contributor

bladyjoker commented Jun 8, 2022

I'm having tests that rely on semantical equality of Json objects, however I'm having issues with Aeson

{"hash":"16574b0f9130f157ccb452cebc00faccfe411b932a2be4fe6e6069cb893d596e","plutusData":{"constr":0,"fields":[{"constr":0,"fields":["",""]},{"constr":0,"fields":["b8aa6f60b48ad4cb0f623edc96eb4dffb652b3a2384287b22c8814ac","5659464974"]},{"constr":0,"fields":["6304d06da03652264996015f08e6d2770ed9a0e57a105ea2c918f05c","56594649745f414441745f6e6674"]},995,7670125982969789,1e+17,"184ff44840c8c0ad71d39e356511660f84e321915bbf76d90bd1969f",{"constr":0,"fields":["6d620e702133d0d4f2273246a36f895b0015c4d385c7cab1aa7c02fd"]},15000000,26075191]}}



{"hash":"16574b0f9130f157ccb452cebc00faccfe411b932a2be4fe6e6069cb893d596e","plutusData":{"constr":0,"fields":[{"constr":0,"fields":["",""]},{"constr":0,"fields":["b8aa6f60b48ad4cb0f623edc96eb4dffb652b3a2384287b22c8814ac","5659464974"]},{"constr":0,"fields":["6304d06da03652264996015f08e6d2770ed9a0e57a105ea2c918f05c","56594649745f414441745f6e6674"]},995,7670125982969789,100000000000000000,"184ff44840c8c0ad71d39e356511660f84e321915bbf76d90bd1969f",{"constr":0,"fields":["6d620e702133d0d4f2273246a36f895b0015c4d385c7cab1aa7c02fd"]},15000000,26075191]}}

Seems like upon reading into Aeons we the BigInt stringified as 1e+17 and then when writing to Aeson we get 100000000000000000.

Since Aeson implements the Eq instance using a stringified form of Json, for semantically the same Json objects we get 2 different textual representations (see above). Let's rather make this right and implement a proper equality instance that captures the semantics of what it means for 2 Json objects to be the same.

@bladyjoker bladyjoker changed the title Aeson Eq instance BigInt issues Make honest Aeson Eq instance Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant