bind<B> method

Evaluation<E, R, W, S, B> bind<B>(
  1. covariant Function1<A, Evaluation<E, R, W, S, B>> f
)
override

Implementation

Evaluation<E, R, W, S, B> bind<B>(Function1<A, Evaluation<E, R, W, S, B>> f) {
  return new Evaluation(_W, (r, s) {
    return new Future.microtask(() {
      return run(r, s).then((leftOrRight) {
        return leftOrRight.fold((e) => new Future.value(new Left(e)), (t) {
          final w1 = t.value1;
          final s2 = t.value2;
          final a = t.value3;
          return f(a).run(r, s2).then((leftOrRight2) {
            return leftOrRight2.map((t2) {
              final w2 = t2.value1;
              final s3 = t2.value2;
              final b = t2.value3;
              return new Tuple3(_W.append(w1, w2), s3, b);
            });
          });
        });
      });
    });
  });
}