How do I compose two coroutine libraries together?...
# arrow
b
How do I compose two coroutine libraries together? E.g., trying to bridge
ktor
and Arrow:
Copy code
val q: (ApplicationCall) -> Kind<ForIO, Unit> = { c -> IO.fx().fx { c.respondText("Foo", ContentType.Text.Html) } }
c.respondText
is a suspending function not in
IO
and
@RestrictsSuspension
on
IO
prevents the composition from occurring that way
s
Copy code
val q: (ApplicationCall) -> IO<Unit> =
  { c ->
    IO.effect { respondText("Foo", ContentType.Text.Html) }
}
As Raul mentioned with
fun <A> effect(f: suspend () -> A): IO<A>
you can lift suspending functions into IO.
b
Is that version of
IO.effect
newer than 0.9.0? The version in 0.9.0 does not take arguments but I really like the syntax
s
Oh yes, that’s on master.