Error Propagation
use
import { Option } from 'funkcia';
declare const safeParseInt: (string: string, radix?: number) => Option<number>;
// ┌─── Option<number>
// ▼
const option = Option.use(function* () {
const x: number = yield* safeParseInt('10');
const y: number = yield* safeParseInt('invalid'); // breaks the circuit, returning Option.None
return Option.some(x + y); // doesn't run
});
// Output: Nonefn
Understanding the use method
Last updated
Was this helpful?