Open mkotsbak opened 4 years ago
Hey @mkotsbak,
We didn't any of these patterns because they typically violate the rules of referential transparency, and for such things you should use IO
. However since IO
is replaced with suspend
and we can do effect mixing instead of effect stacking it's possible to mix suspned
with inline fun Either<A, B>.foreach(f: (A) -> Unit): Unit
in a referential transarent.
We're working hard atm to make Arrow Core a real core FP library. So I'm not sure if we'll add something like that in the future. There is couple alternatives atm but the simplest atm is probably either.orNull()?.let { f(it) }
.
What version are you currently using? 0.11.0
What would you like to see? Side effect running from Either, instead of misusing map/flatMap without return value. Similar to Either.foreach in Scala std. lib: https://www.scala-lang.org/api/2.12.0/scala/util/Either.html#foreach[U](f:B=%3EU):Unit
Btw: https://github.com/typelevel/cats/issues/2193 Is there any better alternative using Arrow?