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

sttp.tapir.integ.cats.effect.CatsMonadError.scala Maven / Gradle / Ivy

package sttp.tapir.integ.cats.effect

import cats.effect.Sync
import sttp.monad.MonadError

class CatsMonadError[F[_]](implicit F: Sync[F]) extends MonadError[F] {
  override def unit[T](t: T): F[T] = F.pure(t)
  override def map[T, T2](fa: F[T])(f: T => T2): F[T2] = F.map(fa)(f)
  override def flatMap[T, T2](fa: F[T])(f: T => F[T2]): F[T2] = F.flatMap(fa)(f)
  override def error[T](t: Throwable): F[T] = F.raiseError(t)
  override protected def handleWrappedError[T](rt: F[T])(h: PartialFunction[Throwable, F[T]]): F[T] = F.recoverWith(rt)(h)
  override def eval[T](t: => T): F[T] = F.delay(t)
  override def suspend[T](t: => F[T]): F[T] = F.defer(t)
  override def flatten[T](ffa: F[F[T]]): F[T] = F.flatten(ffa)
  override def ensure[T](f: F[T], e: => F[Unit]): F[T] = F.guaranteeCase(f)(_ => e)
  override def blocking[T](t: => T): F[T] = F.blocking(t)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy