Пример #1
0
 public static IEnumerable <Eff <B> > Traverse <A, B>(this Eff <IEnumerable <A> > ma, Func <A, B> f) =>
 ma.Match(
     Fail: ex => new [] { FailEff <B>(ex) },
     Succ: xs => xs.Map(x => SuccessEff <B>(f(x)))).Run().Value;
Пример #2
0
 public static Lst <Eff <B> > Traverse <A, B>(this Eff <Lst <A> > ma, Func <A, B> f) =>
 ma.Match(
     Fail: ex => List(FailEff <B>(ex)),
     Succ: xs => xs.Map(x => SuccessEff <B>(f(x)))).Run().Value;
Пример #3
0
 public static Identity <Eff <B> > Traverse <A, B>(this Eff <Identity <A> > ma, Func <A, B> f) =>
 ma.Match(
     Succ: x => new Identity <Eff <B> >(SuccessEff(f(x.Value))),
     Fail: e => new Identity <Eff <B> >(FailEff <B>(e)))
 .Run().Value;