fold<A, B> function
Transforms the TaskOption into a Task, using the given onNone
and onSome
callbacks.
expect(
await some('hello').chain(fold(
() => 'none',
(s) => '$s world',
))(),
'hello world',
);
expect(
await none().chain(fold(
() => 'none',
(s) => '$s world',
))(),
'none',
);
Implementation
Task<B> Function(TaskOption<A> taskOption) fold<A, B>(
B Function() onNone,
B Function(A value) onSome,
) =>
T.map(O.fold(onNone, onSome));