Wesley Hartford
10/05/2022, 5:16 PMsealed 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?simon.vergauwen
10/05/2022, 6:25 PMWesley Hartford
10/05/2022, 6:30 PMWesley Hartford
10/05/2022, 6:53 PM