simple-monad
    Preparing search index...

    Function bad

    • Build a Bad failure leaf from a reason tag, optionally carrying a value payload that describes the failure. Pass value for a rich failure (Bad<R, V>); omit it for a tag-only failure (Bad<R, void>).

      Type Parameters

      • R extends string

        The reason tag.

      • V

        The payload type.

      Parameters

      • reason: R

        The string tag naming the failure.

      • value: V

        Data describing the failure.

      Returns Bad<R, V>

      A Bad wrapping reason and value.

      const r = bad("invalid_price", { price: -5 });
      // Bad<"invalid_price", { price: number }>
    • Build a Bad failure leaf from a reason tag, optionally carrying a value payload that describes the failure. Pass value for a rich failure (Bad<R, V>); omit it for a tag-only failure (Bad<R, void>).

      Type Parameters

      • R extends string

        The reason tag.

      Parameters

      • reason: R

        The string tag naming the failure.

      Returns Bad<R, void>

      A Bad with no payload (Bad<R, void>).