spartanz / schemaz

A purely-functional library for defining type-safe schemas for algebraic data types, providing free generators, SQL queries, JSON codecs, binary codecs, and migration from this schema definition
https://spartanz.github.io/schemaz
Apache License 2.0
164 stars 18 forks source link

WIP: Top-level polymorphic schema definition #7

Closed jdegoes closed 5 years ago

jdegoes commented 6 years ago

Since we are using SchemaModule, we may want to create a top-level, polymorphic definition of a schema. Something like this:

trait Schema[A] {
  def apply(m: SchemaModule): m.Schema[A]
}

Then a user can write:

object PersonSchema extends Schema[Person] {
  def apply(m: SchemaModule): m.Schema[A] = {
    import m._

    // Use everything in `m`
  }
}

If now we had a way to abstract over the primitives required by a schema, it would then be possible to have polymorphic schemas (across, e.g., Scala, JSON, XML, etc.).

vil1 commented 5 years ago

This is (indirectly) addressed by #27

vil1 commented 5 years ago

This was solved/made irrelevant by #27