fromNullableWith<L, R> function
A fromNullable variant that enforces the left and right types. Useful for function composition.
final transform = fromNullableWith<String, int>(() => 'number was missing')
.compose(map((i) => i * 2));
expect(transform(1), right(2));
expect(transform(null), left('number was missing'));
Implementation
Either<L, R> Function(R? value) fromNullableWith<L, R>(
Lazy<L> orElse,
) =>
(value) => fromNullable(value, orElse);