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

ltd.k1nd.pets.dog.syntax.ContainerOps.scala Maven / Gradle / Ivy

The newest version!
package ltd.k1nd.pets.dog.syntax

import cats.arrow.FunctionK
import cats.data.{EitherT, OptionT}
import cats.Functor
import ltd.k1nd.pets.dog.syntax.ContainerOps.ContainerSyntax

trait ContainerOps {
  implicit def createContainerSyntax[F[_], T](
      valueInContext: F[T]): ContainerSyntax[F, T] =
    new ContainerSyntax(valueInContext)
}

object ContainerOps {
  implicit final class ContainerSyntax[F[_], T](val valueInContext: F[T])
      extends AnyVal {
    def liftEitherT[L](implicit m: Functor[F]): EitherT[F, L, T] =
      EitherT.liftF(valueInContext)

    def transform[O[_]](implicit nat: FunctionK[F, O]): O[T] =
      nat(valueInContext)

    def liftOptionT(implicit f: Functor[F]): OptionT[F, T] =
      OptionT.liftF[F, T](valueInContext)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy