kevin-lee / effectie

A Tool for FP Effect Libraries

Home Page:https://effectie.kevinly.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`rethrowIfLeft` and `rethrowTIfLeft` `syntax` for `F[Either[A, B]]` and `EitherT[F, A, B]`

kevin-lee opened this issue · comments

Summary

rethrowIfLeft and rethrowTIfLeft syntax for F[Either[A, B]] and EitherT[F, A, B]

Version

2.0.0-beta12

Description

val fa: IO[Either[Throwable, Int]] = pureOf[IO](Right(1))
fa.rethrowIfLeft
// IO[Int] = IO(1)
val fa: IO[Either[Throwable, Int]] = pureOf[IO](Left(new RuntimeException("Error")))
fa.rethrowIfLeft
// IO[Int] = RaiseError(RuntimeException("ERROR"))
val fa: EitherT[IO, Throwable, Int] = pureOf[IO](Right(1)).eitherT
fa.rethrowTIfLeft
// IO[Int] = IO(1)
val fa: EitherT[IO, Throwable, Int] = pureOf[IO](Left(new RuntimeException("Error"))).eitherT
fa.rethrowTIfLeft
// IO[Int] = RaiseError(RuntimeException("ERROR"))