Giter Site home page Giter Site logo

Add Schema#serializable about zio-schema HOT 3 CLOSED

zio avatar zio commented on July 30, 2024
Add Schema#serializable

from zio-schema.

Comments (3)

aphoristicartist avatar aphoristicartist commented on July 30, 2024

Hi John.
Will it be correct adding additional case for Schema sum type like:

sealed case class SuperSchema(schema: Schema[_]) extends Schema[Schema[_]]

And then pattern match for each type like this:

def serializable: Schema[Schema[_]] =
   self match {
   case p: Schema.Primitive[_] => Schema.SuperSchema(p)
   case Schema.Transform(codec, _, _) => Schema.SuperSchema(codec)
   case _ => ???
 }

Thank you

from zio-schema.

jdegoes avatar jdegoes commented on July 30, 2024

Hi @aphoristicartist ,

In this case, you do not need an additional case.

You can pattern match on "self", and recurse, stripping out all Transform nodes. This will give you a Schema, but without Transform. Then given that Schema, you can, in turn, create another Schema that describes it.

The first step of this problem should be straightforward: create a method called 'withoutTransform' on 'Schema' that returns Schema[_], and it will be the "same" schema, but without any Transform nodes. It has to return a wildcard type because you don't know what the type will be without the Transform nodes.

The next part of the problem, describing the schema of THAT schema, is a little mind-bending. But it will be easier when the first step is completed.

from zio-schema.

thinkharderdev avatar thinkharderdev commented on July 30, 2024

Closed by #83

from zio-schema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.