sangria.catseffect.schema.AsyncValue.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sangria-cats-effect-experimental_2.12 Show documentation
Show all versions of sangria-cats-effect-experimental_2.12 Show documentation
Experimental support for Cats Effect
The newest version!
package sangria.catseffect.schema
import cats.effect.Async
import sangria.schema.LeafAction
import scala.concurrent.ExecutionContext
import scala.language.implicitConversions
case class AsyncValue[Ctx, Val, F[_]: Async](value: F[Val]) extends LeafAction[Ctx, Val] {
override def map[NewVal](fn: Val => NewVal)(implicit
ec: ExecutionContext): AsyncValue[Ctx, NewVal, F] =
new AsyncValue(Async[F].map(value)(fn))
}
object AsyncValue {
implicit def asyncAction[Ctx, Val, F[_]: Async](value: F[Val]): LeafAction[Ctx, Val] =
AsyncValue(value)
}