BindingCompanionVersionSpecific

zio.blocks.schema.binding.BindingCompanionVersionSpecific

The Binding.of methods, which differ between Scala 2 and Scala 3.

Attributes

Source
BindingCompanionVersionSpecific.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Binding

Members list

Value members

Concrete methods

transparent inline def of[A]: Binding[_, A]

Derives a Binding for type A at compile time.

Derives a Binding for type A at compile time.

Supports:

  • Primitive types (Int, String, Boolean, etc.)
  • Case classes and tuples (derives Binding.Record)
  • Case objects and enum cases without parameters (derives a Binding.Record that always returns the object)
  • Sealed traits, sealed abstract classes and enums (derives Binding.Variant)
  • Option, Either, and their subtypes
  • zio.blocks.schema.DynamicValue
  • A class with one field whose companion has an apply from the field's type to Either[E, A] (derives a Binding.Wrapper whose wrap calls apply and throws a SchemaError on a Left)
  • Structural types, on the JVM only
  • zio-prelude newtypes (derives Binding.Wrapper)
  • On Scala 3 only: named tuples (derives Binding.Record), union types (derives Binding.Variant, with the cases sorted by the full name of each case's type, not in the order the union is written) and opaque types (derives Binding.Wrapper)

On Scala 3, a structural record type needs a build of this library with Scala 3.5 or later; a union of structural types does not. Both Scala 3 artifacts are such builds (zio-blocks-schema with Scala 3.9, zio-blocks-next-schema with Scala 3.10). (In 0.0.56, zio-blocks-schema was built with Scala 3.3 and rejected structural record types at compile time.)

For sequence types (List, Vector, etc.) and map types, use the overloads that take type constructors: Binding.of[List], Binding.of[Map]; Binding.of[List[Int]] does not compile.

Type parameters

A

the type to derive a binding for

Attributes

Returns

the derived binding

Source
BindingCompanionVersionSpecific.scala
inline def of[F[_]](using sc: SeqConstructor[F], sd: SeqDeconstructor[F]): Seq[F, Nothing]

Creates a Binding.Seq for a sequence type constructor from the implicit SeqConstructor and SeqDeconstructor instances. The resulting binding has element type Nothing, which upcasts to any element type via covariance.

Creates a Binding.Seq for a sequence type constructor from the implicit SeqConstructor and SeqDeconstructor instances. The resulting binding has element type Nothing, which upcasts to any element type via covariance.

Type parameters

F

the sequence type constructor (e.g., List, Vector)

Attributes

Source
BindingCompanionVersionSpecific.scala
inline def of[M[_, _]](using mc: MapConstructor[M], md: MapDeconstructor[M]): Map[M, Nothing, Nothing]

Creates a Binding.Map for a map type constructor from the implicit MapConstructor and MapDeconstructor instances. The resulting binding has key and value types Nothing, which upcast via covariance.

Creates a Binding.Map for a map type constructor from the implicit MapConstructor and MapDeconstructor instances. The resulting binding has key and value types Nothing, which upcast via covariance.

Type parameters

M

the map type constructor (e.g., Map)

Attributes

Source
BindingCompanionVersionSpecific.scala