Skip to main content
Version: 2.x

How to Migrate from Monix to ZIO?

Monix's Task[A] can be easily replaced with ZIO's Task[A] (an alias for ZIO[Any, Throwable, A]). Translation should be relatively straightforward. Below, you'll find tables showing the ZIO equivalents of monix.eval.Task's methods.

Once you've completed the initial translation, you'll find that ZIO is outfitted with many additional methods which have no Monix equivalents, so have fun exploring the API and see if you can rewrite some of your logic at a higher level of abstraction, with more powerful combinators and fewer lines code.

If you are using operators from Cats Effect extension methods see also here.

Methods on Trait

MonixZIO
attempteither
bracketCaseacquireReleaseExitWith
bracketEacquireReleaseExitWith
bracketacquireReleaseWith
delayExecutiondelay
dematerializeabsolve
doOnCancelonInterrupt
doOnFinishonExit
failedflip
flatMapflatMap
flattenflatten
guaranteeCaseensuringExit
guaranteeensuring
loopForeverforever
materializeeither
memoizememoize
onErrorFallbackToorElse
onErrorHandleWithcatchAll
onErrorRecoverWithcatchSome
onErrorRestartretryN
redeemWithfoldZIO
redeemfold
restartUntilrepeatUntil
startfork
timedtimed
timeouttimeout
uncancelableuninterruptible

Methods on Companion Object

MonixZIO
applyapply
asyncFasyncZIO
asyncasync
cancelableasyncInterrupt
deferFuturefromFuture
defersuspend
delayattempt
evalattempt
fromEitherfromEither
fromFuturefromFuture
fromTryfromTry
map2mapN
mapBothmapParN
nevernever
nowsucceed
parMap2mapParN
parSequenceNcollectAllParN
parSequencecollectAllPar
parTraverseNforeachParN
parTraverseforeachPar
parZip2tupledPar
puresucceed
racePairraceWith
raceraceFirst
raiseErrorfail
sequencecollectAll
shiftyield
sleepsleep
suspendsuspend
traverseforeach
unitunit

Data Structures

Monix / Cats EffectZIO
DeferredPromise
FiberFiber
MVarQueue
RefRef
SemaphoreSemaphore
TaskAppApp
TaskLocalFiberRef
TaskTask