fromNullableK<A, L, R> function
A wrapper for fromNullable, that returns a function that accepts a value to be transformed.
final transform = fromNullableK(
(String s) => s == 'hello' ? s : null,
() => 'it was not hello',
);
expect(
transform('hello'),
right('hello'),
);
expect(
transform('asdf'),
left('it was not hello'),
);
Implementation
Either<L, R> Function(A value) fromNullableK<A, L, R>(
R? Function(A value) f,
L Function(A value) orElse,
) =>
(value) => fromNullable(f(value), () => orElse(value));