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

ZIO Schema doesn't differentiate Either[L, R] from fallback semantics #584

Closed
gnp opened this issue Jul 16, 2023 · 5 comments
Closed

ZIO Schema doesn't differentiate Either[L, R] from fallback semantics #584

gnp opened this issue Jul 16, 2023 · 5 comments

Comments

@gnp
Copy link

gnp commented Jul 16, 2023

ZIO Schema has both support for a member of type Either[L, R] via Schema.either and for something that appears to be intended for fallback via Schema.orElseEither, but the latter just encodes to the same thing as the former. And, when you go to use it, you do not actually get fallback semantics. For example, you cannot use it to decode JSON "[42, "43"]" to something that can either decode from Long or String.

This is demonstrated in this Scastie: https://scastie.scala-lang.org/gnp/078lqgCNRjuNBwvnOPyWFg/10

@jdegoes
Copy link
Member

jdegoes commented Jan 8, 2024

/bounty $350

This addition to ZIO Schema would be a true fallback, which will encode properly, and attempt decode left first, followed by right if that fails. Because decoding either side could succeed, this implies that use of such a fallback operator will violate laws for union data that is encoded ambiguously.

Bounty for addition of the feature, updating existing codecs, and test suite.

Copy link

algora-pbc bot commented Jan 8, 2024

💎 $350 bounty created by ZIO
🙋 If you start working on this, comment /attempt #584 to notify everyone
👉 To claim this bounty, submit a pull request that includes the text /claim #584 somewhere in its body
📝 Before proceeding, please make sure you can receive payouts in your country
💵 Payment arrives in your account 2-5 days after the bounty is rewarded
💯 You keep 100% of the bounty award
🙏 Thank you for contributing to zio/zio-schema!

👉 Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @pablf Jan 14, 2024, 6:34:08 PM #645

@pablf
Copy link
Member

pablf commented Jan 14, 2024

/attempt #584

Options

Copy link

algora-pbc bot commented Jan 20, 2024

💡 @pablf submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Copy link

algora-pbc bot commented Jan 20, 2024

🎉🎈 @pablf has been awarded $350! 🎈🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants