Skip to content

IOOptionOps<A>

extension IOOptionOps<A> on Option<A>

Methods

traverseIO() extension

IO<Option<B>> traverseIO<B>(IO<B> Function(A) f)

If this is a Some, returns the result of applying f to the value, otherwise an IO with a None is returned.

Available on Option<A>, provided by the IOOptionOps<A> extension

Implementation
dart
IO<Option<B>> traverseIO<B>(Function1<A, IO<B>> f) =>
    fold(() => IO.none(), (a) => f(a).map((a) => Some(a)));

traverseIO_() extension

IO<Unit> traverseIO_<B>(IO<B> Function(A) f)

Same behavior as traverseIO but the resulting value is discarded.

Available on Option<A>, provided by the IOOptionOps<A> extension

Implementation
dart
IO<Unit> traverseIO_<B>(Function1<A, IO<B>> f) =>
    fold(() => IO.unit, (a) => f(a).map((_) => Unit()));