Sam Pengilly
07/27/2023, 4:01 AMior(...) {} one?simon.vergauwen
07/27/2023, 7:05 AMSam Pengilly
07/27/2023, 7:09 AMSam Pengilly
07/27/2023, 7:09 AMsimon.vergauwen
07/27/2023, 7:09 AMbind on Either in Ior. Doesn't that work? ๐คSam Pengilly
07/27/2023, 7:10 AMsimon.vergauwen
07/27/2023, 7:10 AMsimon.vergauwen
07/27/2023, 7:11 AMLeft it does short-circuit but we could also figure out some API that allows for accumulation if providing a default value as you say. That'd be pretty neatSam Pengilly
07/27/2023, 7:12 AMsimon.vergauwen
07/27/2023, 7:13 AMIor shinessimon.vergauwen
07/27/2023, 7:13 AMSam Pengilly
07/27/2023, 7:15 AMbindOrAccumulate on Either inside an IorRaise scope, a clear operation that will bind a Right value or accumulate the Left value into a Both in the Ior rather than short circuiting.
Thoughts?simon.vergauwen
07/27/2023, 7:21 AMSam Pengilly
07/27/2023, 7:22 AMSam Pengilly
07/27/2023, 7:24 AMSam Pengilly
07/27/2023, 7:28 AMignoreErrors {} and define the semantics of the operation in the builder... So you might have an ior {} builder that binds eithers by short circuiting, but also providing an iorAccumulateErrors {} builder which doesn't short circuit and accumulates every error on bind.Sam Pengilly
07/27/2023, 7:28 AMnullable {}, either {}, etcSam Pengilly
07/27/2023, 7:32 AMrecover function inside NullableRaise.
iorNel {
// Recovers to null and accumulates the error in the Left case
val value = eitherFunc().recover { null }
}Sam Pengilly
07/27/2023, 7:34 AMSam Pengilly
07/27/2023, 7:34 AMsimon.vergauwen
07/27/2023, 7:42 AMalso providing anThat wouldn't work because what do you provide on the left hand side ofbuilder which doesn't short circuit and accumulates every error on bind.iorAccumulateErrors {}
bind.
val either: Either<String, Int> = "fail"
iorAccumulateErrors(String::plus) {
val x: Int = either.bind()
x + 1
}
You cannot accumulate, and continue here.simon.vergauwen
07/27/2023, 7:43 AMrecover is probably confusing too, there is recover in ior but it ignores the error since you recovered from it.simon.vergauwen
07/27/2023, 7:43 AMresulting in typing/intellisensing two method names instead of one slightly longer oneThe first that came to mind for me was
bindOrGet but I think that's not a good nameSam Pengilly
07/27/2023, 7:44 AMbindOrAccumulate is probably still the best option? ๐
simon.vergauwen
07/27/2023, 7:44 AMsimon.vergauwen
07/27/2023, 7:44 AMgetAndAccumulate ๐คSam Pengilly
07/27/2023, 7:45 AMsimon.vergauwen
07/27/2023, 7:45 AMSam Pengilly
07/27/2023, 7:46 AMSam Pengilly
07/27/2023, 7:46 AMsimon.vergauwen
07/27/2023, 7:46 AM