We have imperative style builders for async progra...
# coroutines
r
We have imperative style builders for async programs over coroutines that can target IO, Observable, Flowable and Deferred with the same syntax. Not sure if it applies to this problem but the calls here to
bind()
can be flagged to be async.
Copy code
IO.monad().binding {
    val file = getFile("/tmp/file.txt").bind()
    val lines = file.readLines().bind()
    val average = 
      if (lines.isEmpty()) {
        0
      } else {
        val count = lines.map { it.length }.foldLeft(0) { acc, lineLength -> acc + lineLength }
        count / lines.length
      }
    yields(average)
  }
  .ev()
  .attempt()
  .unsafeRunAsync()
http://arrow-kt.io/docs/effects/io/ http://arrow-kt.io/docs/effects/async/ @pakoito worked on all the effects and async stuff and knows more about Rx than I do but if the question is if you can do async jumps in imperative style with coroutines without flatMap chains (rx) or callbacks (old school) I think it can be done with suspended continuations and still suspend and capture side effects.