chainTryCatchK<A, B> function

Option<B> Function(Option<A> a) chainTryCatchK<A, B>(
  1. B f(
    1. A value
    )
)

A variant of tryCatchK, that allows for passing in an Option. If the Option is Some, then the value is unwrapped and passed into the function.

expect(
  some(10).chain(chainTryCatchK((i) => i > 5 ? throw 'fail' : i)),
  some(10),
);
expect(
  some(3).chain(chainTryCatchK((i) => i > 5 ? throw 'fail' : i)),
  none(),
);

Implementation

Option<B> Function(Option<A> a) chainTryCatchK<A, B>(B Function(A value) f) =>
    flatMap(tryCatchK(f));