Deriver

zio.schema.Deriver
See theDeriver companion object
trait Deriver[F[_]] extends VersionSpecificDeriver[F]

Deriver builds type class instances based on a Schema.

The minimum set of methods to implement are:

  • deriveRecord
  • deriveEnum
  • derivePrimitive
  • deriveOption
  • deriveSequence
  • deriveMap
  • deriveTransformedRecord (for records with more than 22 fields)

In addition to this more methods can be overridden to handle all the supported Schema types of zio-schema:

  • deriveEither (calls deriveEnum by default)
  • deriveSet (calls deriveSequence by default)
  • deriveTupleN (calls deriveRecord by default)

The cached method converts this deriver to one that uses a cache of instances shared between macro invocations.

Each derive methods get an optional summoned implicit value of the derived type class. It is the deriver's decision whether to use the available instance (as a user defined customization for a given type) or not.

If the decision is to always accept a summoned value if there is any, use the Deriver.AutoAcceptSummoned trait which implements this automatically and only calls the trait's methods in case there is no available implicit for the actual type.

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Concise view

Value members

Abstract methods

def deriveEnum[A](enum: Enum[A], cases: => Chunk[WrappedF[F, _]], summoned: => Option[F[A]]): F[A]
def deriveMap[K, V](map: Map[K, V], key: => F[K], value: => F[V], summoned: => Option[F[Map[K, V]]]): F[Map[K, V]]
def deriveOption[A](option: Optional[A], inner: => F[A], summoned: => Option[F[Option[A]]]): F[Option[A]]
def derivePrimitive[A](st: StandardType[A], summoned: => Option[F[A]]): F[A]
def deriveRecord[A](record: Record[A], fields: => Chunk[WrappedF[F, _]], summoned: => Option[F[A]]): F[A]
def deriveSequence[C[_], A](sequence: Sequence[C[A], A, _], inner: => F[A], summoned: => Option[F[C[A]]]): F[C[A]]
def deriveTransformedRecord[A, B](record: Record[A], transform: Transform[A, B, _], fields: => Chunk[WrappedF[F, _]], summoned: => Option[F[B]]): F[B]

Concrete methods

def deriveEither[A, B](either: Either[A, B], left: => F[A], right: => F[B], summoned: => Option[F[Either[A, B]]]): F[Either[A, B]]
def derivePrimitiveAlias[A : ClassTag, U](st: StandardType[U], summoned: => Option[F[A]]): F[A]
def deriveSet[A](set: Set[A], inner: => F[A], summoned: => Option[F[Set[A]]]): F[Set[A]]
def deriveTupleN[T](schemasAndInstances: => Chunk[(Schema[_], WrappedF[F, _])], summoned: => Option[F[T]]): F[T]
def deriveUnknown[A : ClassTag](summoned: => Option[F[A]]): F[A]
def tryDeriveEnum[A : ClassTag](schema: Schema[A], cases: => Chunk[WrappedF[F, _]], summoned: => Option[F[A]]): F[A]
def tryDeriveRecord[A : ClassTag](schema: Schema[A], fields: => Chunk[WrappedF[F, _]], summoned: => Option[F[A]]): F[A]

Inherited methods

inline def derive[A](implicit schema: Schema[A]): F[A]

Attributes

Inherited from:
VersionSpecificDeriver

Concrete fields

lazy val cached: Deriver[F]