Youssef Shoaib [MOD]
05/03/2025, 11:55 PMinline fun <A> doubleNegationElimination(block: ((A) -> Nothing) -> Nothing): A = merge { block(this::raise) }
For more info
Bonus: suspend
allows the same thing (which is precisely why early raise builders were made using suspend
magic):
suspend fun <A> doubleNegationElimination(block: suspend (suspend (A) -> Nothing) -> Nothing): A = suspendCoroutine { cont ->
block.startCoroutine({ value ->
suspendCoroutine<Nothing> {
cont.resume(value)
}
}, cont)
}
simon.vergauwen
05/05/2025, 7:10 AMYoussef Shoaib [MOD]
05/05/2025, 7:12 AMsuspend
to work (a CPS transform is similar to a double-negation translation from classical logic to intuitionistic logic). This allows us access to the "mother of all monads", which I consider a definite plus!