stojan
12/23/2019, 6:40 PMIO
fails?Tesserakt
12/23/2019, 6:42 PMflatTap
. It perform an effect without changing the result.
IO(1).map { it + 2 }
.flatTap {
IO.effect { log.debug(it) }
}
The result of this code is 3 and in console you can see 3stojan
12/23/2019, 6:46 PMTesserakt
12/23/2019, 6:46 PMstojan
12/23/2019, 6:46 PMfun <A> IO<A>.logError(log: (Throwable, () -> String) -> IO<Unit>, msg: () -> String): IO<A> =
handleErrorWith { log(it, msg).followedBy(IO.raiseError(it)) }
stojan
12/23/2019, 6:47 PMlog
is the function that logsstojan
12/23/2019, 6:47 PMTesserakt
12/23/2019, 7:01 PMattempt
and folding either... Not so clean as yourpakoito
12/24/2019, 12:53 AMhandleErrorWith { IO { log(it, msg }.followedBy(IO.raiseError(it)) }
yeppakoito
12/24/2019, 12:53 AMSagar Suri
12/24/2019, 2:20 AMEitherT<IO, A, B>
this will help.stojan
12/24/2019, 11:09 AMSagar Suri
12/24/2019, 11:10 AMstojan
12/24/2019, 11:32 AMpakoito
12/24/2019, 11:34 AMpakoito
12/24/2019, 11:35 AMJannis
12/24/2019, 11:40 AM