SchemaVersionSpecific

zio.blocks.schema.SchemaVersionSpecific

Adds structural to Schema.

Attributes

Source
SchemaVersionSpecific.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Schema[A]
Self type
Schema[A]

Members list

Value members

Concrete methods

transparent inline def structural(using ts: ToStructural[A]): Schema[ts.StructuralType]

Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.

Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.

On Scala 3 the result has the structural type. On Scala 2 its static type is Schema[ts.StructuralType]: the compiler does not see the refinement, so the result cannot be assigned to a Schema of the structural type.

The conversion is available on the JVM only, because structural types need reflection.

case class Book(title: String, year: Int)

val structural = Schema.derived[Book].structural

Value parameters

ts

the macro-generated conversion to the structural type

Attributes

See also
Source
SchemaVersionSpecific.scala