Hi, I'm playing with the effects and I found out t...
# arrow
t
Hi, I'm playing with the effects and I found out that
Copy code
sealed interface DomainError
object SomeDomainError: DomainError

fun foo(): Effect<DomainError, Unit> = TODO()
fun bar(): Effect<SomeDomainError, Unit> = TODO()

fun baz() = effect<DomainError, Unit> {
    foo().bind()
    bar().bind()
}
the problem is I cannot bind result of
bar
even though
SomeDomainError
is a
DomainError
. Is this known limitation, oversight, or weirdness on my side 🙂 ?
i
We could make Effect
E
and
A
invariant contravariant like in Either than this compiles fine
s
We have some options here I think. Make
R
contravariant/out in
Effect<R, A>
, or define
bind
as
suspend fun <EE : E, A> Effect<EE, A>.bind(): A
in
EffectScope<E>
.
We can release 1.1.3 with such a fix
i
contravariant as simon said, I meant out but keep switching them out everynow and then 😅