I'm just starting to work with effects. It seems l...
# arrow
w
I'm just starting to work with effects. It seems like the following code should be allowed:
Copy code
sealed interface LeftResult
sealed interface DatabaseLeftResult: LeftResult
sealed interface ApiLeftResult: LeftResult

fun queryDatabase() = effect<DatabaseLeftResult, Int> { 42 }
fun submitNumber(number: Int) = effect<ApiLeftResult, Unit> { println(number) }
fun queryAndSubmit() = effect<LeftResult, Unit> {
  val number = queryDatabase().bind()
  submitNumber(number).bind()
}
However, both of the
bind
calls in
queryAndSubmit
result in an unresolved reference error. If I make
queryDatabase
and
submitNumber
use
LeftResult
on the left rather than the sub-interface, the code compiles. I can also change the
bind
call to
.toEither().bind()
and the code compiles. Shouldn't my original code compile though?
s
Hey @Wesley Hartford, What version are you using? Your code example compiles fine for me with 1.1.3.
w
Ahh, I'm on 1.1.2, I've been putting off the upgrade. I'll test that out now.
Thank you @simon.vergauwen, Upgrading to 1.1.3 fixed that issue.