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

[avro] Add Either typeclass support #1004

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

[avro] Add Either typeclass support #1004

wants to merge 2 commits into from

Conversation

RustedBones
Copy link
Contributor

Support scala Either as a avro type union

Comment on lines +263 to +267
// `Either[A, B]` is a `UNION` of `[A, B]` and must default to first type `A`
override def makeDefault(d: Either[A, B])(cm: CaseMapper): fa.ToT = {
require(d.isLeft, "Either[A, B] can only default to Left[A]")
fa.to(d.left.get)(cm): @nowarn
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In scala Either is Right biased but here I chose Left as possible default based on type order definition. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems reasonable IMO

Copy link

codecov bot commented Jul 22, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.31%. Comparing base (2c10ba9) to head (bb2dcee).

Files with missing lines Patch % Lines
avro/src/main/scala/magnolify/avro/AvroType.scala 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1004      +/-   ##
==========================================
- Coverage   95.34%   95.31%   -0.03%     
==========================================
  Files          56       56              
  Lines        1978     1987       +9     
  Branches      154      157       +3     
==========================================
+ Hits         1886     1894       +8     
- Misses         92       93       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Support scala Either as a avro type union
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 this pull request may close these issues.

2 participants