public static PairAndMonoid <X, C> SelectMany <X, A, B, C>(this PairAndMonoid <X, A> ps, Func <A, PairAndMonoid <X, B> > p, Func <A, B, C> f) { return(SelectMany(ps, a => Select(p(a), b => f(a, b)))); }
public static PairAndMonoid <X, B> SelectMany <X, A, B>(this PairAndMonoid <X, A> ps, Func <A, PairAndMonoid <X, B> > f) { var r = f(ps.b); return(new PairAndMonoid <X, B>(Pair <X, B> .pair(ps.M.Op(ps.a, r.a), r.b), ps.M)); }
public static PairAndMonoid <X, B> Select <X, A, B>(this PairAndMonoid <X, A> ps, Func <A, B> f) { return(new PairAndMonoid <X, B>(ps.Pair.Select(f), ps.M)); }
public PairAndMonoid <A, Pair <B, C> > Zip <C>(PairAndMonoid <A, C> o) { return(ZipWith <C, Pair <B, C> >(o, Pair <B, C> .pairF())); }
public PairAndMonoid <A, D> ZipWith <C, D>(PairAndMonoid <A, C> o, Func <B, Func <C, D> > f) { return(this.SelectMany(a => o.Select(b => f(a)(b)))); }
public PairAndMonoid <A, Pair <B, C> > Zip <C>(PairAndMonoid <A, C> o) => ZipWith(o, Pair <B, C> .pairF());