<@UE7URQL10> I would go to a terminal `IO&lt;Unit&...
# arrow
r
@noiano I would go to a terminal
IO<Unit>
then at the very edge where you need to perform the action you can call
unsafeRunAsync
or any other variation of that method to run the program. What
attempt
does is turn
IO<A>
into
IO<Either<Throwable, A>>
forcing the receiver of the last typed value to deal in composition with the fact that the operation may have failed with an exception which can be found in the Left
n
woud runAsync block the current thread? or will it run a separated thread therefore requiring me to do some sort of
Copy code
waitForCompletion
kinda thing?
given the name I’d say the second
s
You can either use
unsafeRunSync()
which blocks the callers thread or
unsafeRunAsync { }
which allows the run
IO
to fork execution
You can also use
unsafeRynAsyncCancellable { }
which returns a
typealias Disposable = () -> Unit
which you can use to cancel the running
IO
.
IO
cancelation gets checked on
flatMap
boundaries.
n
Thank you so much... I need to block otherwise the program exits and with that the spark session is killed
s
Any time 🙂 Awesome to see Arrow being used with Spark!
Haven’t seen a lot of Spark in Kotlin yet
n
Yeah because it's not good since you have to use the spark Java API
But it's company mandated so I cannot switch to scala...at least I can ease the pain with kotlin
s
Hopefully Arrow can fill some gaps as well 👍
n
Oh absolutely
It's a godsend
❤️ 1