IOIListOps<A>
extension IOIListOps<A> on IList<A>Methods
flatTraverseIO() extension
Applies f to each element of this list and collects the results into a new list that is flattened using concatenation. If an error or cancelation is encountered for any element, that result is returned and any additional elements will not be evaluated.
Available on IList<A>, provided by the IOIListOps<A> extension
Implementation
IO<IList<B>> flatTraverseIO<B>(Function1<A, IO<IList<B>>> f) =>
traverseIO(f).map((a) => a.flatten());parTraverseIO() extension
Asynchronously applies f to each element of this list and collects the results into a new list. If an error or cancelation is encountered for any element, that result is returned and all other elements will be canceled if possible.
Available on IList<A>, provided by the IOIListOps<A> extension
Implementation
IO<IList<B>> parTraverseIO<B>(Function1<A, IO<B>> f) {
IO<IList<B>> result = IO.pure(nil());
foreach((elem) {
result = IO.both(result, f(elem)).map((t) => t((acc, b) => acc.prepended(b)));
});
return result.map((a) => a.reverse());
}parTraverseIO_() extension
Asynchronously applies f to each element of this list, discarding any results. If an error or cancelation is encountered for any element, that result is returned and all other elements will be canceled if possible.
Available on IList<A>, provided by the IOIListOps<A> extension
Implementation
IO<Unit> parTraverseIO_<B>(Function1<A, IO<B>> f) {
IO<Unit> result = IO.pure(Unit());
foreach((elem) {
result = IO.both(result, f(elem)).map((t) => t((acc, b) => Unit()));
});
return result;
}traverseFilterIO() extension
Applies f to each element of this list and collects the results into a new list. Any results from f that are None are discarded from the resulting list. If an error or cancelation is encountered for any element, that result is returned and any additional elements will not be evaluated.
Available on IList<A>, provided by the IOIListOps<A> extension
Implementation
IO<IList<B>> traverseFilterIO<B>(Function1<A, IO<Option<B>>> f) => traverseIO(f).map(
(opts) => opts.foldLeft(
IList.empty<B>(),
(acc, elem) => elem.fold(() => acc, (elem) => acc.appended(elem)),
),
);traverseIO() extension
Applies f to each element of this list and collects the results into a new list. If an error or cancelation is encountered for any element, that result is returned and any additional elements will not be evaluated.
Available on IList<A>, provided by the IOIListOps<A> extension
Implementation
IO<IList<B>> traverseIO<B>(Function1<A, IO<B>> f) {
IO<IList<B>> result = IO.pure(nil());
foreach((elem) {
result = result.flatMap((l) => f(elem).map((b) => l.prepended(b)));
});
return result.map((a) => a.reverse());
}traverseIO_() extension
Applies f to each element of this list, discarding any results. If an error or cancelation is encountered for any element, that result is returned and any additional elements will not be evaluated.
Available on IList<A>, provided by the IOIListOps<A> extension
Implementation
IO<Unit> traverseIO_<B>(Function1<A, IO<B>> f) {
var result = IO.pure(Unit());
foreach((elem) {
result = result.flatMap((l) => f(elem).map((b) => Unit()));
});
return result;
}