Is it possible to compose one `IO.fx` object in an...
# arrow
c
Is it possible to compose one
IO.fx
object in another
IO.fx
object?
s
Yes, you can.
c
How is it done?
Copy code
val program = IO.fx {
    !effect {performSideEffect()}
    !effect {performSideeffect()}
}

val program2 = IO.fx {
    // I'd like to call program here
    program
    !effect {anotherSideEffect()}
}

fun main(..) {
    unsafe { runBlocking {program2}}
}
s
Copy code
val program2 = IO.fx {
    // I'd like to call program here
    !program
    !effect {anotherSideEffect()}
}
You can call
program
by applying it with
!
. Just like you do for
{ anotherSideEffect() }
.
c
Ahh
that makes total sense. Since
program
is already an IO object I can just use
!
on it. For some reason I kept trying different variants of
!effect { program }
which was not working
thank you
s
You’re very welcome!! 🙂