Skip to main content
Version: 2.0.0-beta13

Fx Cheat sheet

After importing syntax,

import effectie.syntax.all._

Construct

FxCats EffectFutureTry
pureOf(a)Sync[F].pure(a)Future.successful(a)Success(a)
effectOf(a)Sync[F].delay(a)Future(a)Try(a)
pureOrError(a)Sync[F].catchNonFatal(a)Future.fromTry(Try(a))Try(a)
unitOf[F]Sync[F].unitFuture.unitSuccess(())
errorOf[F][A](e)Sync[F].raiseError[A](e)Future.failed(e)Failure(e)
note

a: A
e: Throwable

Error Handling

FxCats EffectFutureTry
fa.catchNonFatalThrowablefa.attemptfa.transform {...}fa match { ... }
fb.catchNonFatal { ... }fa.attempt.flatMap { ... }fa.transform {...}.flatMapfa match { ... }.flatMap
fa.handleNonFatal(e => A)fa.handleError(a => A)fa.recoverWith(e => Future(A))fa.recoverWith(e => Try(A))
fa.handleNonFatalWith(e => F[A])fa.handleNonFatalWith(a => F[A])fa.recoverWith(e => Future[A])fa.recoverWith(e => Try(A))
fa.recoverFromNonFatal { case e => A }fa.handleErrorWith { case e => A.pure[F] or raise e }fa.recover { case e => A }fa.recover { case e => A }
fa.recoverFromNonFatalWith { case e => F[A] }fa.handleErrorWith { case e => F[A] or raise e }fa.recoverWith { case e => Future[A] }fa.recoverWith { case e => Try(A) }
note

a: A
b: B
fa: F[A]
fb: F[B]
e: Throwable

...More will be added...