https://kotlinlang.org logo
#arrow
Title
# arrow
d

dave08

03/05/2023, 2:56 PM
Hi! What could this error be?
Copy code
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public open operator fun <A> (EagerEffect<BaseError, TypeVariable(A)> /* = Raise<BaseError>.() → TypeVariable(A) */).invoke(): TypeVariable(A) defined in arrow.core.raise.Raise
public open suspend operator fun <A> (suspend Raise<BaseError>.() → TypeVariable(A)).invoke(): TypeVariable(A) defined in arrow.core.raise.Raise
The function is this:
Copy code
fun interface RecordConnectionAndGetAccountUseCase {
    suspend operator fun Raise<DomainError>.invoke(state: State): Account
}
And I'm trying to call this from an either block...
Oh... I had to write this
Copy code
with(recordConnection) { invoke(state) }
😵‍💫
Kinda defeats the purpose of the invoke operator there... another reason to wait for context receivers... meanwhile I guess I should be using
either { }
everywhere instead...?
s

simon.vergauwen

03/06/2023, 8:16 AM
Why are you using
fun interface
there? 🤔 Having two receivers is indeed very annoying, and in case of a method the functions already have a receiver. Depending on you code usage etc that can be less, or more of a problem. Using
Either
doesn't have this issue ye.
d

dave08

03/06/2023, 10:09 AM
Why are you using
fun interface
there
Before I introduced Arrow, it was easier to test interactions between use cases like that 😄... just make a lambda as a Fake... I'd suppose you're proposing to just make that into a top-level function, which would avoid the receiver problem... but then injecting Fakes wouldn't be possible. I guess there isn't any way to have the best of both worlds... avoiding the extra `either`s while not being able to use context receivers to call them in a sane way 😢.
14 Views