resB if resA is a Ok.
const success = ok<number>(2);
const failure = err("not a 2");
const lateError = err("late error");
const earlyError = err("early error");
const anotherSuccess = ok("different result");
expect(and(lateError)(success)).toStrictEqual(lateError);
expect(and<number, string>(success)(earlyError)).toStrictEqual(earlyError);
expect(and(lateError)(failure)).toStrictEqual(failure);
expect(and(anotherSuccess)(success)).toStrictEqual(anotherSuccess);
Returns
resBifresAis anOk, otherwise returns the errorresA. The order of arguments is reversed because of that it is useful for partial applying.