Function toOkOrElseErr

  • Transform the Maybe into a Result, using the wrapped value as the Ok value if Just; otherwise using elseFn to generate Err.

    Type Parameters

    • T

      The wrapped value.

    • E

      The error type to in the Result.

    Parameters

    • elseFn: () => E

      The function which generates an error of type E.

    • maybe: Maybe<T>

      The Maybe instance to convert.

    Returns Result<T, E>

    A Result containing the value wrapped in maybe in an Ok, or the value generated by elseFn in an Err.

  • Transform the Maybe into a Result, using the wrapped value as the Ok value if Just; otherwise using elseFn to generate Err.

    Type Parameters

    • T

      The wrapped value.

    • E

      The error type to in the Result.

    Parameters

    • elseFn: () => E

      The function which generates an error of type E.

    Returns (maybe: Maybe<T>) => Result<T, E>

    A Result containing the value wrapped in maybe in an Ok, or the value generated by elseFn in an Err.