Match Made

Exhaustive pattern matching on unions

Why it matters

  • `match()` exhaustively covers a discriminated union of statuses.
  • Inline destructuring keeps success and error copies declarative.
match()pipe()Console Console.capture()Exception.tryCatch()
Program
const message = (status: Status): string =>
  match(status, {
    Pending: () => "⏳ Awaiting review",
    Approved: ({by}) => `✅ By ${by}`,
    Rejected: ({reason}) => `${reason}`,
  });

Awaiting execution

Console output, timeline events will render here after you run the program.

Handlers: Console.capture() · Exception.tryCatch()