simple-monad
    Preparing search index...

    Chaining

    The instance side of Result: lift a leaf, transform it, fold it. Reach for this when you have a pipeline of transforms; a single branch is usually better served by the leaves alone.

    • Result.from(res) — the bridge from the simple layer: lifts an Ok / Bad leaf (or their union) into a Result. It is the only way to construct one — the constructor is private.
    • .map(f) — transform the success value; a failure passes through untouched, its tag and payload intact.
    • .match({ ok, bad }) — collapse both rails to a single value. The bad arm is a per-reason map (same shape as matchBad), and each arm is required only when its rail is inhabited.
    • .toUnion() — the inverse of from: drop back to the Ok | Bad leaf union, where the leaf guards narrow.

    The wrapper is for chaining, not narrowing — it deliberately has no isOk() / isBad() guards. See 05 — Chaining with the Result wrapper for a worked pipeline.