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

refined4s.modules.doobie.derivation.generic.auto.scala Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package refined4s.modules.doobie.derivation.generic

import cats.*
import doobie.{Get, Put}
import refined4s.{Coercible, RefinedCtor}

/** @author Kevin Lee
  * @since 2023-12-16
  */
trait auto {

  inline given derivedPut[A, B](using coercible: Coercible[A, B], put: Put[B]): Put[A] =
    put.contramap(coercible(_))

  inline given derivedRefinedGet[A, B](using refinedCtor: RefinedCtor[B, A], getA: Get[A], showA: Show[A]): Get[B] =
    getA.temap(refinedCtor.create)

  inline given derivedNewtypeGet[A, B](using coercible: Coercible[A, B], getA: Get[A]): Get[B] =
    getA.map(coercible(_))

}
object auto extends auto




© 2015 - 2024 Weber Informatics LLC | Privacy Policy