mlabs-haskell / mlabs-haskell/purescript-aeson

Make honest Aeson Eq instance

Open
#7 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Nix
Stars
6
Forks
7
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Aeson Eq instance and the BigInt parsing and encoding path described in the report. Compare the two numeric representations in the supplied examples and define semantic equality for Json; done means equivalent values compare equal without changing distinct values.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.