tofu.internal.instances.SleepInstance.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tofu-kernel_3 Show documentation
Show all versions of tofu-kernel_3 Show documentation
Opinionated set of tools for functional programming in Scala
package tofu.internal
package instances
import cats.~>
import tofu.higherKind.{RepK, RepresentableK}
import tofu.internal.carriers.{SleepCE2Carrier, SleepCE3Carrier}
import tofu.time.Sleep
import scala.compiletime.summonFrom
import scala.concurrent.duration.FiniteDuration
private[tofu] trait SleepInstance:
inline given [F[_]]: Sleep[F] =
summonFrom {
case carrier: SleepCE3Carrier[F] => carrier
case carrier: SleepCE2Carrier[F] => carrier
}
// TODO: use higherKind.derived macro when it is ready for scala 3
given sleepRepresentableK: RepresentableK[Sleep] = new RepresentableK[Sleep] {
def tabulate[F[_]](hom: RepK[Sleep, _] ~> F): Sleep[F] = new Sleep[F] {
def sleep(duration: FiniteDuration): F[Unit] = hom(RepK[Sleep](_.sleep(duration)))
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy