ToStructural

zio.blocks.schema.ToStructural
See theToStructural companion object
trait ToStructural[A]

Type class for converting nominal schemas to structural schemas.

Given a Schema[A] for a nominal type like a case class, this type class generates the corresponding structural type and provides a conversion method.

Example:

// scala-3-only
case class Person(name: String, age: Int)

val nominalSchema: Schema[Person] = Schema.derived[Person]
val structuralSchema: Schema[{ def name: String; def age: Int }] = nominalSchema.structural

In Scala 2 the compiler does not see the refined StructuralType, so nominalSchema.structural has type Schema[ts.StructuralType] and cannot be assigned to a Schema of the structural type.

Note: This is JVM-only due to reflection requirements for structural types.

Attributes

Companion
object
Source
ToStructural.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Type members

Types

Attributes

Source
ToStructural.scala

Value members

Abstract methods

def apply(schema: Schema[A]): Schema[StructuralType]

Attributes

Source
ToStructural.scala