How to use the monet.Either.of function in monet

To help you get started, we’ve selected a few monet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github char0n / monad-t / src / FlutureTMonetEither / index.js View on Github external
let value;
      let state = iterator.next();

      while (!state.done) {
        value = yield state.value.run.chain((either) => {
          if (either.isLeft()) {
            return Future.reject(either.left());
          }

          return Future.of(either.right());
        });

        state = iterator.next(value);
      }

      return Either.of(state.value);
    })
  );
github char0n / monad-t / src / MonetEitherT / index.js View on Github external
function MonetEitherT(monad, isRightValue = true) {
  if (isUndefined(new.target)) {
    if (isNotNull(FlutureTMonetEither) && isFuture(monad)) {
      return FlutureTMonetEither.fromFuture(monad);
    } else if (monad instanceof Identity.fn.init) {
      return Either.of(monad.get());
    } else if (monad instanceof Either.fn.init && isNotNull(FlutureTMonetEither)) {
      return FlutureTMonetEither.fromEither(monad);
    }
    return new MonetEitherT(monad);
  }

  this.run = monad;
  this.isRightValue = isRightValue;
}