fromOption<A, B> function

TaskEither<A, B> Function(Option<B> option) fromOption<A, B>(
  1. A leftValue(
      )
    )

    Converts an o.Option<B> into a TaskEither<A, B> based on whether the option contains a value or not.

    If the option is of type o.Some, the resulting TaskEither will contain the encapsulated value of type B in its e.Right side. If the option is of type o.None, the provided function leftValue will be invoked and its result will be wrapped in the e.Left side of the resulting TaskEither.

    This allows transforming optional values into asynchronous computations that can produce either a value or an error.

    Usage:

    final maybeValue = o.Some(5);
    final fallback = () => "No value found";
    final taskEither = fromOption<int, String>(fallback)(maybeValue);
    
    // If `maybeValue` was o.Some(5), `taskEither` will now contain a Right with value 5.
    // If `maybeValue` was o.None(), `taskEither` will contain a Left with the result of `fallback`.
    

    Implementation

    TaskEither<A, B> Function(o.Option<B> option) fromOption<A, B>(
            A Function() leftValue) =>
        (o.Option<B> option) => option is o.Some<B>
            ? right<A, B>(option.value)
            : left<A, B>(leftValue());