zio.blocks.schema.ToStructural
See theToStructural companion object
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
Members list
In this article