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

Typeclass derivation macro #428

Merged
merged 22 commits into from
Nov 17, 2022
Merged

Typeclass derivation macro #428

merged 22 commits into from
Nov 17, 2022

Conversation

vigoo
Copy link
Contributor

@vigoo vigoo commented Nov 13, 2022

Resolves #419

This is a generic typeclass derivation macro that provides unified interface for Scala 2 and Scala 3 to derive any user defined type classes for data types having a Schema which is isomorphic to the schema generated by DeriveSchema.gen.

Additional to the new type class derivation feature, it also contains several improvements to the Scala 3 version of the DeriveSchema.gen macro:

  • It now properly refines the generated case class schemas with static field name information (WithFields etc)
  • Support for case class and enum with arities higher than 22
  • Support for case object
  • Handles tuples the same way as Scala 2 (supporting only arities 2..4)
  • I was able to delete the version specific (2.12, 2.13 and 3 separate) schema derivation test suites and have a single one
  • Also seems to fix (with a version-specific implicit definition) the issue defined in Reimplement the Scala 3 schema derivation without Mirror #395

@vigoo vigoo marked this pull request as ready for review November 16, 2022 21:53
@vigoo vigoo requested a review from a team as a code owner November 16, 2022 21:53
throw new IllegalStateException(s"CachedDeriver uses explicit deriveTupleN overrides")
}

object CachedDeriver {
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this whole file private and expose via Deriver#cached?

@jdegoes jdegoes merged commit 6da1e72 into zio:main Nov 17, 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

Successfully merging this pull request may close these issues.

Ability to capture implicit typeclass instances within the schema
2 participants