All Downloads are FREE. Search and download functionalities are using the official Maven repository.

zio.schema.Factory.scala Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package zio.schema

/**
 * Useful to create factory methods.
 * 
 * import Factory._
 * def createSomeTrait[A: Factory](deriver: Deriver[SomeTrait])(implicit schema: Schema[A]): SomeTrait[A] = 
 *    implicitly[Factory[A]].derive[SomeTrait](deriver)
 * 
 */
trait Factory[A] {
  def derive[F[_]](deriver: Deriver[F])(implicit schema: Schema[A]): F[A]
}

object Factory {

  inline implicit def factory[A]: Factory[A] = new Factory[A] {
    override def derive[F[_]](deriver: Deriver[F])(implicit schema: Schema[A]): F[A] = Derive.derive[F, A](deriver)(schema)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy