Abstract altconst inputNull: number | null = null as number | null;
opt(inputNull).altOpt(null) // None
opt(inputNull).altOpt(1) // Some(1)
opt(2).altOpt(1) // Some(2)
type Handler = (_: number) => void;
const userHandler: Handler | null = a => console.log('user handling', a);
const systemHandler: Handler | null = a => console.log('system handling', a);
const backupHandler: Handler | null = a => console.log('backup handling', a);
const panicHandler: Handler = a => console.log('PANIC handling', a);
const handler =
  opt(userHandler)
    .altOpt(systemHandler)
    .altOpt(backupHandler)
    .orElse(panicHandler);
handler(250 + 64); // prints "user handling 314"
Return
thisfor Some,defwrapped inoptfor None.