pablisco
09/29/2021, 4:01 PMpablisco
09/29/2021, 4:01 PMleftValue.bindLeft()
rightValue.bindRight()
And potentially the same for other types:
nullable.bindOr { fallbackLeft }
option.bindOr { fallbackLeft }
result.bindOr { e -> someOtherLeftFrom(e) }simon.vergauwen
09/29/2021, 4:05 PMsimon.vergauwen
09/29/2021, 4:06 PMsimon.vergauwen
09/29/2021, 4:07 PMpablisco
09/29/2021, 6:19 PMsimon.vergauwen
09/30/2021, 10:44 AMpablisco
09/30/2021, 10:52 AMsimon.vergauwen
09/30/2021, 11:05 AMRestrictSuspension but without limiting suspensionMarc
09/30/2021, 12:08 PMsimon.vergauwen
09/30/2021, 2:35 PMbind without wrapping in either { }.
Here ensureNotNull comes from either { }, and this function can only be called inside either<MyError, A> but potentially you can write your whole domain code like this without having Either in the return type.
@Context(EitherEffect<MyError, Any?>)
suspend fun ProductRepo.fetchUsers(): List<User> =
  ensureNotNull(fetch("SQL QUERY")) { MyError("Users not found") }simon.vergauwen
09/30/2021, 2:37 PMEither<E, A> but you also want access to the EitherEffect<E,  Any?>.
So currently we can only add special functions for the DSL inside Arrow Core but with multiple receivers you can add special DSL functions from outside the library also.
@Context(EitherEffect<E, Any?>)
suspend fun <E> Either<E, A>.customDSL(): A {
  val a = this.bind()
  // DSL logic
  a
}
either<E, A> {
   1.right().customDSL()
}Marc
09/30/2021, 3:11 PMEitherEffect?simon.vergauwen
09/30/2021, 3:12 PMEitherEffect is the receiver of the either { } dsl.
Here either<E, A> { this }, this is EitherEffect<E, Any?>simon.vergauwen
09/30/2021, 3:12 PMcustomDSL inside either { }