commonMain.reader.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kontinuity-jvm Show documentation
Show all versions of kontinuity-jvm Show documentation
Provides fully-fledged multishot delimitied continuations in Kotlin with Coroutines
The newest version!
import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn
public suspend fun Reader.ask(): T = suspendCoroutineUninterceptedOrReturn {
findNearestSplitSeq(it).find(this)
}
public suspend fun Reader.askOrNull(): T? = suspendCoroutineUninterceptedOrReturn {
findNearestSplitSeq(it).findOrNull(this)
}
public suspend fun runReader(value: T, fork: T.() -> T = { this }, body: suspend Reader.() -> R): R =
with(Reader()) {
pushReader(value, fork) { body() }
}