If you have an operation like this ```suspend fun...
# arrow
c
If you have an operation like this
Copy code
suspend fun foo() = either {
  val foo = !getFoo()
  val bar = !getBar()
  val foobar = !foobarFactory.make(foo, bar)
}
are
foo
and
bar
evaluated concurrently and then
foobar
once its dependencies have resolved? I’m trying to get a better overview of how arrow handles these suspended functions. Currently we are using
either.eager
, but I’d like to better understand the non-blocking
either
so I can benefit from that.
s
Hey @Cody Mikol, They're not evaluated concurrently, the program executes sequentially here just like
either.eager
does. The only difference between
either.eager
and
either
is that in the latter you can call
suspend fun
from inside the
{ }
block.
c
That makes total sense, thank you 🙂
👍 1
s
If you want to make them run in parallel you can use Arrow Fx Coroutines inside
either { }
like so.
Copy code
suspend fun foo() = either {
  val (foo, bar) = parZip(
    { getFoo().bind() },
    { getBar().bind() })
    { foo, bar -> Pair(foo, bar) }

  val foobar = !foobarFactory.make(foo, bar)
}
😍 1
c
That is exactly what I’m looking for
Thanks for all your work on arrow, it has totally changed the way I think about writing programs
2
arrow 2