# arrow

Stylianos Gakis

02/01/2023, 3:50 PM
In the docs of the
function, a code snippet is attached:
Copy code
suspend fun main() {
  effect<String, Int> {
    shift("SHIFT ME")
  }.fold({ it shouldBe "SHIFT ME" }, { fail("Computation never finishes") })
Here shift knows what
(the return type) is due to it being the last in the function so it’s
. When shift isn’t used at the end like that, one would need to explicitly pass something to be able to call shift, otherwise it won’t know what
is. How is this typically supposed to be used? Is explicitly passing a type there the expected approach while calling that function? And in reality, if I am only calling shift to short-circuit, I won’t use the return value, so should it just be
? For now I realized doing just
ensure(condition) { LeftType }
was what I wanted, but how about other cases?


02/01/2023, 3:52 PM
shift is getting renamed to
in 2.0 and the return type is no longer a generic
representing the exit but just
This means that in the future
only cares about the left type of the effect. If you don't ascribe the type in the effect it won't be able to infer Int in the right same as your example. I think the issue would still be the same but raise no longer depends on it. Here the issue is none of your function return an Int because they all exit with failures or shift

Stylianos Gakis

02/01/2023, 4:01 PM
Right, I knew I must’ve missed some discussion about this, thanks a lot for the clarification, this makes a lot of sense yeah! And this example was simply from the shift docs, hence I linked it here as an example. In my particular case I had the Right response down lower, but it’s as you described still a problem. The 2.0 syntax would fit exactly what I was going for 😎