Hey, I’m trying to use the `Either.resolve` extens...
# arrow
k
Hey, I’m trying to use the
Either.resolve
extension function that is commented as “resolving some suspended function” however, the function parameter is not of a suspended type. Would this be a problem with the docs, the implementation or my understanding? https://github.com/arrow-kt/arrow/blob/main/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt#L1175-L1199
e
It's inlined. Think of it as being copy-pasted into the place where you call it.
k
I understand that much, what I don’t understand is that if it’s resolving some suspended function, shouldn’t that mean that it should be resolving some actual provided suspended function as the
f
parameter?
e
Ah.. I see, now I'm also a bit confused.. 🙂
you mean why the type of
f
isn't
suspend () -> Either<E, A>
, instead of
() -> Either<E, A>
?
k
Yeah, that’s exactly my confusion
p
Because it’s inlined at the call-site, the body of
f
is directly called within the same scope - if it contains suspending calls then they would fall under the same constraints as if you’d written them directly in the call-site rather than in the lambda. As such, the call-site would have to be suspending if the block contained suspending calls.