IO

sealed interface IO<out R> : Effect<R> (source)

Real, possibly asynchronous, I/O. A handler that needs it translates its effects into performIO binds, and one suspend runner at the edge, io or on the JVM ioBlocking(), runs them all:

fun <A> Program<A>.consoleAsync(): Program<A> =
handle<Console<*>, A> { op ->
when (op) {
is Print -> performIO { sendToRemoteLog(op.line) }.bind()
ReadLine -> performIO { fetchInputFromApi() }.bind()
}
}

val name = greeter.consoleAsync().io()

Inheritors

Types

Link copied to clipboard
class Suspend<R> : IO<R>

Run thunk and respond with its result.