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

Add a SumEncoding option that's somewhere between a TaggedObject and an UntaggedValue #827

Open
poscat0x04 opened this issue Jan 17, 2021 · 1 comment · May be fixed by #828
Open

Add a SumEncoding option that's somewhere between a TaggedObject and an UntaggedValue #827

poscat0x04 opened this issue Jan 17, 2021 · 1 comment · May be fixed by #828

Comments

@poscat0x04
Copy link

Sometimes the tag and the content of the JSON you're processing are on the same level where both TaggedObject and UntaggedValue will not suffice. I propose adding another SumEncoding option that handles this case. The implementation should be very similar to that of UntaggedValue.

@poscat0x04 poscat0x04 changed the title Add a SumEncoding options that's somewhere between a TaggedObject and an UntaggedValue Add a SumEncoding option that's somewhere between a TaggedObject and an UntaggedValue Jan 17, 2021
@poscat0x04
Copy link
Author

Hmmm, this is tricky to implement for constructors that do not have field names. We cannot drop them cause then we will lose the roundtrip property. Maybe we should use the position as the key when encoding and decoding. For example, A 1 1 should be encoded to

{
  "tag": "A",
  "1" : 1,
  "2": 1
}

where A is defined as

data A = A Int Int | B Int Int

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

Successfully merging a pull request may close this issue.

1 participant