Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
require('fantasy-land');
const { Future } = require('fluture');
const { Identity, Either } = require('monet');
const { MonetEitherT: EitherT } = require('monad-t');
const { FlutureTMonetEither: FutureTEither } = require('monad-t');
EitherT(Identity.of(1)); // => Either.Right(1)
FutureTEither.of(Future.of(Either.Right(1))); // => FlutureTMonetEither(1)
FlutureTMonetEither.prototype.and = function and(futureEither) {
return this.constructor.of(
Future
.of(either1 => either2 => either1.chain(always(either2)))
.ap(this.run)
.ap(futureEither.run)
);
};
value = yield state.value.run.chain((either) => {
if (either.isLeft()) {
return Future.reject(either.left());
}
return Future.of(either.right());
});
const liftEither = m => FlutureTMonetEither.of(Future.of(m));
FlutureTMonetEither.fromValue = function fromValue(val) {
return this[of](Future.of(Either.Right(val)));
};
FlutureTMonetEither.fromEither = function fromEither(either) {
return this[of](Future.of(either));
};
return this[chain](val => this.constructor.of(Future.of(fn(val))));
};