runFuture method

Future<R> runFuture()

{@category execution}

Implementation

Future<R> runFuture() async {
  try {
    final result = _unsafeRun(Context.env(null));
    if (result is! Future) {
      return switch (result) {
        Left(value: final cause) => throw cause,
        Right(value: final value) => value,
      };
    }

    return switch (await result) {
      Left(value: final cause) => throw cause,
      Right(value: final value) => value,
    };
  } on Cause<L> {
    rethrow;
  } catch (error, stackTrace) {
    throw Die(error, stackTrace);
  }
}