cps.monads.scalaz.ScalazIOCpsMonad.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cps-async-connect-scalaz_3 Show documentation
Show all versions of cps-async-connect-scalaz_3 Show documentation
cps-async-connect: integration of dotty-cps-async with effect stacks
The newest version!
package cps.monads.scalaz
import cps._
import scalaz._
import scalaz.effect._
import scala.util.Try
given scalazIO: CpsTryMonad[IO] with CpsMonadInstanceContext[IO] with
type F[T] = IO[T]
def pure[A](a:A): IO[A] = IO(a)
def map[A,B](fa: IO[A])(f: A=>B): IO[B] =
fa.map(f)
def flatMap[A,B](fa: IO[A])(f: A=>IO[B]): IO[B] =
fa.flatMap(f)
def error[A](e: Throwable): IO[A] =
IO.throwIO[A](e)
def flatMapTry[A,B](fa: IO[A])(f: Try[A]=>IO[B]) =
fa.catchLeft.flatMap{
_.fold( e => f(scala.util.Failure(e)), a => f(scala.util.Success(a)) )
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy