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

Allow pattern matching on Schema for tuples, eithers #18

Closed
jdegoes opened this issue Mar 2, 2021 · 2 comments
Closed

Allow pattern matching on Schema for tuples, eithers #18

jdegoes opened this issue Mar 2, 2021 · 2 comments

Comments

@jdegoes
Copy link
Member

jdegoes commented Mar 2, 2021

Tuples and eithers (products/sums) are so core to schema that we should bake them in and allow pattern matching against them, rather than encoding them atop Record / Enum.

@jdegoes
Copy link
Member Author

jdegoes commented Mar 3, 2021

A hint getting started:

final case class SchemaTuple2[A, B](left: Schema[A], right: Schema[B]) extends Schema[(A, B)]
final case class SchemaEither2[A, B](left: Schema[A], right: Schema[B]) extends Schema[Either[A, B]]

This way, if you have a Schema[A], you can match against it to see if it's Tuple or Either, and then knowing this, you can extract out left / right sides as appropriate.

@sviezypan
Copy link
Contributor

let me take this one

jdegoes pushed a commit that referenced this issue Apr 5, 2021
* #16 Enhance codec with non-streaming methods

* #18 added tuples and eithers

* #18 formatted code

* #18 added one failing test scenario

* #18 introduced either schema also for json codec

* #18 fixed json either encoding bug

* #18 fixed nested products bugs

* #18 fixed complex nested sum types

* #18 formatted code

* #18 removed unnecessary comments

Co-authored-by: Damian Reeves <957246+DamianReeves@users.noreply.github.com>
jdegoes pushed a commit that referenced this issue Apr 20, 2021
* #16 Enhance codec with non-streaming methods

* #18 added tuples and eithers

* #18 formatted code

* #18 added one failing test scenario

* #18 introduced either schema also for json codec

* #18 fixed json either encoding bug

* #18 fixed nested products bugs

* #18 fixed complex nested sum types

* #18 formatted code

* #18 removed unnecessary comments

* Refactoring of protobuf decoder, sequence decoder bug fixes

* rename test method

Co-authored-by: Damian Reeves <957246+DamianReeves@users.noreply.github.com>
@jdegoes jdegoes closed this as completed Apr 22, 2021
landlockedsurfer pushed a commit to landlockedsurfer/zio-schema that referenced this issue May 28, 2022
* zio#16 Enhance codec with non-streaming methods

* zio#18 added tuples and eithers

* zio#18 formatted code

* zio#18 added one failing test scenario

* zio#18 introduced either schema also for json codec

* zio#18 fixed json either encoding bug

* zio#18 fixed nested products bugs

* zio#18 fixed complex nested sum types

* zio#18 formatted code

* zio#18 removed unnecessary comments

Co-authored-by: Damian Reeves <957246+DamianReeves@users.noreply.github.com>
landlockedsurfer pushed a commit to landlockedsurfer/zio-schema that referenced this issue May 28, 2022
* zio#16 Enhance codec with non-streaming methods

* zio#18 added tuples and eithers

* zio#18 formatted code

* zio#18 added one failing test scenario

* zio#18 introduced either schema also for json codec

* zio#18 fixed json either encoding bug

* zio#18 fixed nested products bugs

* zio#18 fixed complex nested sum types

* zio#18 formatted code

* zio#18 removed unnecessary comments

* Refactoring of protobuf decoder, sequence decoder bug fixes

* rename test method

Co-authored-by: Damian Reeves <957246+DamianReeves@users.noreply.github.com>
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

No branches or pull requests

2 participants