I'm trying to see if I can create a statefull mess...
# arrow
m
I'm trying to see if I can create a statefull message processing loop that runs in IO. I was trying to see if I could make it a tail recursive function so that I could avoid mutation. Eg:
Copy code
tailrec fun myActor(context: Context, controlChannel: ReceiveChannel<Message>) : IO<Unit> = IO.fx {
    val newContext = context.handleMessage(controlChannel) // Returns IO<Context>
    myActor(newContext, controlChannel).bind()
}
However when I put my recursive call inside an IO.fx block, it doesn't recognize the recursive call as a tail call (which makes sense). Is there some mechanism in Arrow for allowing this or some other recommended way to do this?