This has probably been asked before, but I couldn’t find it from a quick search. Why doesn’t
shift
return
Nothing
?
It’s declared as
suspend fun <B> shift(r: R): B
but it could instead be
suspend fun shift(r: R): Nothing
The reason I ask is specifically because of this use case:
var failure: MyFailure? = null
val effect = eagerEffect<MyFailure, String> {
failure?.let { shift(it) } // "Not enough information to infer type variable B"
"some result"
}
The fix is to be explicit about the
Nothing
type, which feels super weird:
val effect = eagerEffect<MyFailure, String> {
failure?.let { shift<Nothing>(it) }
"some result"
}