```myThing .flatTap { element: String -> IO {...
# functional
p
Copy code
myThing
  .flatTap { element: String -> IO { log(element) } }
  .flatMap { element: String -> continueProgram(element) }
d
@pakoito Thank you very much for the advice. It always pays back to read the whole documentation of the library you are using 🙂.
flatTap
is what I was looking for.
😍 1
We use
IO<Either<E, R>>
a lot so we use
EitherT
a lot too. Is there any way to provide
IO<B>
to EitherT’s
flatTap
? The compiler insists on
IO<Either>
, so I ended up with this snippet:
Copy code
.flatTap(IO.monad()) { events ->
                        EitherT(IO
                                .effect { logger.debug { "Leger: <$ledgerId> has events: <$events>" } }
                                .map { Unit.right() })
                    }
p
yikes
it looks correct
so in 0.11 we'll have IO<E, A> and you won't need EitherT
0.10.5 is the last release of that series
d
I will try to hide it in extension function. I can’t wait to use 0.11 🙂