Hi! There was an article in this channel about how...
# arrow
g
Hi! There was an article in this channel about how to replace IO or Observable, or Async with arrow fx. Something in context of continuation and suspend-functions
r
Most of the APIs and examples are here https://arrow-kt.io/docs/fx/async/
That shows the IO concurrent and async operators directly over suspend
The rest is changing IO<A> for Suspend<A>
Where you used to do map, flatMap etc you can just use suspend function application instead
Should see significant code reduction and callback reduction as well if you were using map and flatmap
s
Where you looking for this specifically? https://github.com/arrow-kt/arrow-fx/tree/0.11.0.1/arrow-fx-coroutines There are indeed some things there that haven't been moved to the website 🤔 They are now replaced with a README explaining the internals of the library.
g
I just remember that there was an interesting example, where author moves flatMap so code looks like synchronous. And there was something about continuations and monads
s
Hmm, I think you're refering to the old documentation. https://arrow-kt.io/docs/0.10/fx/
r
g
s
Here is a document on
IO
, https://github.com/arrow-kt/arrow/tree/master/arrow-docs/docs/io. For
Single
, and
Observable
pretty much the same principles apply but we recommend to use the official KotlinX Coroutines RxJava module to interopt. https://github.com/Kotlin/kotlinx.coroutines/tree/master/reactive/kotlinx-coroutines-rx2 And then you can do something like this.
Copy code
object Data
suspend fetchData(): Data = TODO()

val res: Single<Pair<Data, Data>> = rxSingle {
  parMapN({ fetchData() }, { fetchData() }, ::Pair)
}