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

Generic derivation of "Isos" #47

Open
vil1 opened this issue Jan 20, 2019 · 0 comments
Open

Generic derivation of "Isos" #47

vil1 opened this issue Jan 20, 2019 · 0 comments
Labels

Comments

@vil1
Copy link
Member

vil1 commented Jan 20, 2019

From the user's point of view, the most tedious part of defining a schema is writing the values of the iso field of unions and records.

For instance, in ordre to define the schema for a class

final case class Foo(i: Int, l: Long, s: String, b: Boolean)

one must implement an Iso[(Int, (Long, (String, (Boolean)))), Foo], which is 100% boilerplate.

Using generic programming, it is possible to derive automatically at compile time an Iso between any case class (product type) and its "nested tuples" representation. We should provide such a way in the generic module using scalaz-deriving.

This issue must be solved without modifying the existing API for building schemas (namely, the public methods in SchemaModule).

An acceptable solution would be to define some Generic* module extending SchemaModule with two methods :

  • caseClass* allowing to define a Record by simply providing a "product of labelled fields" (with automatic derivation of the iso)
  • sealedTrait* allowing to define an Union by simply providing a "sum of labelled branches (with automatic derivation of the iso)

Important note

This issue should be solved while taking into account the results of #44.

*: these names are merely suggested names

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

No branches or pull requests

1 participant