Johan Basson
11/10/2020, 6:19 AMSatyam Agarwal
11/10/2020, 6:23 AMthan_
11/10/2020, 8:34 AMeither{
someData.map{ yourFuncThatReturnsEither(it).bind() }
}
Scott Christopher
11/10/2020, 10:19 AMEither.tailRecM
, which has a bit of a confusing signature (particularly when dealing with Either). https://arrow-kt.io/docs/apidocs/arrow-core-data/arrow.core/-either/tail-rec-m.html
If the type you're working with is Either<DomainError, Id>
, the type signature is something like:
<A> Either.tailRecM(repeatedValue: A, (A) -> Either<DomainError, Either<A, Id>>) : Either<DomainError, Id>
Scott Christopher
11/10/2020, 10:23 AMA
(which can be any type), and it is repeatedly given to the provided function, which is expected to return either a Left<DomainError>
in the case of an error, Right<Left<A>>
if you need to loop again with a new A
, or a Right<Right<Id>>
when you're done.Scott Christopher
11/10/2020, 10:23 AMtailRecM
is that it should be stack safe.pakoito
11/10/2020, 11:28 AMtailrec suspend fun
where you use either { }
, or tailrecM
julian
11/10/2020, 2:37 PMparSequence
and takeWhile
as you recommend? Thanks.Satyam Agarwal
11/10/2020, 2:41 PMlistOf(1,2,3,5)
.map { element ->
suspend { doSomethingWithElement(element) }
}
.parSequenceN(semaphoreLimit)
.takeWhile { p -> p.isRight() }
its raw but I basically changed real use case to thisSatyam Agarwal
11/10/2020, 2:45 PMjulian
11/10/2020, 2:56 PMJohan Basson
11/24/2020, 4:52 PM