Exemplo n.º 1
0
 public static Task <R> match <T, R>(TryAsync <T> self, Func <T, R> Succ, R Fail) =>
 self.Match(Succ, Fail);
Exemplo n.º 2
0
 public Func <Unit, Task <S> > FoldBackAsync <S>(TryAsync <A> ma, S state, Func <S, A, Task <S> > f) => _ =>
 default(MTryFirstAsync <A>).MatchAsync(ma, x => f(state, x), () => state);
Exemplo n.º 3
0
 public Task <bool> IsSome(TryAsync <A> opt) =>
 Match(opt, Some: _ => true, None: () => false);
Exemplo n.º 4
0
 public Task <Unit> Match(TryAsync <A> opt, Action <A> Some, Action None) =>
 Match(opt,
       x => { Some(x); return(unit); },
       () => { None(); return(unit); });
Exemplo n.º 5
0
 public Task <Unit> MatchAsync(TryAsync <A> opt, Action <A> Some, Func <Task> NoneAsync) =>
 MatchAsync(opt,
            x => { Some(x); return(unit); },
            async() => { await NoneAsync().ConfigureAwait(false); return(unit); });
Exemplo n.º 6
0
 public static Task <Arr <T> > toArray <T>(TryAsync <T> tryDel) =>
 tryDel.ToArray();
Exemplo n.º 7
0
 public static TryAsync <A> append <SEMI, A>(TryAsync <A> lhs, TryAsync <A> rhs) where SEMI : struct, Semigroup <A> =>
 lhs.Append <SEMI, A>(rhs);
Exemplo n.º 8
0
 public static Task <int> count <T>(TryAsync <T> self) =>
 self.Count();
Exemplo n.º 9
0
 public static Task <bool> exists <T>(TryAsync <T> self, Func <T, bool> pred) =>
 self.Exists(pred);
Exemplo n.º 10
0
 public static Task <S> fold <S, T>(TryAsync <T> self, S state, Func <S, T, S> Succ, Func <S, Exception, S> Fail) =>
 self.BiFold(state, Succ, Fail);
Exemplo n.º 11
0
 public static Task <bool> forall <T>(TryAsync <T> self, Func <T, bool> pred) =>
 self.ForAll(pred);
Exemplo n.º 12
0
 public static Task <S> fold <S, T>(TryAsync <T> self, S state, Func <S, T, S> folder) =>
 self.Fold(state, folder);
Exemplo n.º 13
0
 /// <summary>
 /// Invokes a delegate with the result of the TryAsync computation if it is successful.
 /// </summary>
 /// <typeparam name="T">Type of the bound value</typeparam>
 /// <param name="self">TryAsync computation</param>
 /// <param name="action">Delegate to invoke on successful invocation of the TryAsync computation</param>
 public static Task <Unit> iter <T>(TryAsync <T> self, Action <T> action) =>
 self.Iter(action);
Exemplo n.º 14
0
 /// <summary>
 /// Pattern matches the two possible states of the TryAsync computation
 /// </summary>
 /// <typeparam name="T">Type of the bound value</typeparam>
 /// <param name="self">TryAsync computation</param>
 /// <param name="Succ">Delegate to invoke if the TryAsync computation completes successfully</param>
 /// <param name="Fail">Delegate to invoke if the TryAsync computation fails</param>
 public static Task <Unit> match <T>(TryAsync <T> self, Action <T> Succ, Action <Exception> Fail) =>
 self.Match(Succ, Fail);
Exemplo n.º 15
0
 public static TryAsync <A> plusFirst <A>(TryAsync <A> ma, TryAsync <A> mb) =>
 default(MTryFirstAsync <A>).Plus(ma, mb);
Exemplo n.º 16
0
 public static TryAsync <R> map <T, R>(TryAsync <T> self, Func <T, R> mapper) =>
 self.Map(mapper);
Exemplo n.º 17
0
 public static Task <Lst <T> > toList <T>(TryAsync <T> tryDel) =>
 tryDel.ToList();
Exemplo n.º 18
0
 public static TryAsync <R> bimap <T, R>(TryAsync <T> tryDel, Func <T, R> Succ, Func <Exception, R> Fail) =>
 tryDel.BiMap(Succ, Fail);
Exemplo n.º 19
0
 public static TryAsync <A> choice <A>(TryAsync <A> ma, params TryAsync <A>[] tail) =>
 choice(Cons(ma, tail));
Exemplo n.º 20
0
 public static TryAsync <Func <T2, Func <T3, R> > > parmap <T1, T2, T3, R>(TryAsync <T1> self, Func <T1, T2, T3, R> func) =>
 self.ParMap(func);
Exemplo n.º 21
0
 public static TryAsync <A> add <NUM, A>(TryAsync <A> lhs, TryAsync <A> rhs) where NUM : struct, Num <A> =>
 lhs.Add <NUM, A>(rhs);
Exemplo n.º 22
0
 public static TryAsync <T> filter <T>(TryAsync <T> self, Func <T, bool> pred) =>
 self.Filter(pred);
Exemplo n.º 23
0
 public Task <Unit> MatchAsync(TryAsync <A> opt, Func <A, Task> SomeAsync, Action None) =>
 MatchAsync(opt,
            async x => { await SomeAsync(x).ConfigureAwait(false); return(unit); },
            () => { None(); return(unit); });
Exemplo n.º 24
0
 public static TryAsync <T> bifilter <T>(TryAsync <T> self, Func <T, bool> Succ, Func <Exception, bool> Fail) =>
 self.BiFilter(Succ, Fail);
Exemplo n.º 25
0
 public Task <Unit> MatchAsync(TryAsync <A> opt, Func <A, Task> SomeAsync, Func <Task> NoneAsync) =>
 MatchAsync(opt,
            async x => { await SomeAsync(x).ConfigureAwait(false); return(unit); },
            async() => { await NoneAsync().ConfigureAwait(false); return(unit); });
Exemplo n.º 26
0
 public static TryAsync <R> bind <T, R>(TryAsync <T> tryDel, Func <T, TryAsync <R> > binder) =>
 tryDel.Bind(binder);
Exemplo n.º 27
0
 public Func <Unit, Task <int> > Count(TryAsync <A> ma) => _ =>
 default(MTryFirstAsync <A>).Match(ma, x => 1, () => 0);
Exemplo n.º 28
0
 public static TryAsync <R> bibind <T, R>(TryAsync <T> self, Func <T, TryAsync <R> > Succ, Func <Exception, TryAsync <R> > Fail) =>
 self.BiBind(Succ, Fail);
Exemplo n.º 29
0
 public TryAsync <A> Append(TryAsync <A> x, TryAsync <A> y) =>
 Plus(x, y);
Exemplo n.º 30
0
 public static TryAsync <T> flatten <T>(TryAsync <TryAsync <TryAsync <TryAsync <T> > > > self) =>
 self.Flatten();