Exemple #1
0
 public static MonadicValue <TInput> Do <TInput>(this MonadicValue <TInput> o, params Action <TInput>[] actions)
 {
     foreach (var action in actions)
     {
         action(o.Value);
     }
     return(o);
 }
Exemple #2
0
        public static MonadicValue <TInput> Map <TInput>(this MonadicValue <TInput> o, params Func <TInput, TInput>[] funcs)
        {
            var result = o;

            foreach (var func in funcs)
            {
                result = func(result);
            }
            return(result);
        }
 public TypeMatcherContext(MonadicValue <TV> contextValue)
 {
     this.contextValue = contextValue;
 }
Exemple #4
0
 public static MonadicValue <TResult> Bind <TInput, TResult>(this MonadicValue <TInput> o, Func <TInput, MonadicValue <TResult> > f) => f(o.Value);
Exemple #5
0
 public static MaybeTypeMatcher <TV, T11> TypeMatch <TV, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this FuncState <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> s,
                                                                                                       MonadicValue <TV> value, Func <TypeMatcherContext <TV>, Func <Func <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, T11>, MaybeTypeMatcher <TV, T11> > f) => f(value.TypeMatch(), s.Func);
Exemple #6
0
 public static MaybeTypeMatcher <TV, T4> TypeMatch <TV, T1, T2, T3, T4>(this FuncState <T1, T2, T3, T4> s,
                                                                        MonadicValue <TV> value, Func <TypeMatcherContext <TV>, Func <Func <T1, T2, T3, T4>, T4>, MaybeTypeMatcher <TV, T4> > f) => f(value.TypeMatch(), s.Func);
Exemple #7
0
 public MatcherMemberAccessor(MonadicValue <TV> contextValue) : base(contextValue)
 {
 }
 public static MonadicValue <TU> Match <TV, TU>(this MonadicValue <TV> v, TypeMatcher <TU> matcher) => matcher.Match(v.Value).ToM();
 public static ListMatcherContext <TV> Match <TV>(this MonadicValue <TV[]> v) => new ListMatcherContext <TV>(v.With(x => x as IEnumerable <TV>));
Exemple #10
0
 public static IEnumerable <MonadicValue <T> > Lift <T>(this MonadicValue <IEnumerable <T> > v) => v.Value.Select(z => z.ToM());
Exemple #11
0
 public static MonadicValue <TInput> ApplyUnless <TInput>(this MonadicValue <TInput> o, Func <TInput, bool> evaluator, Func <TInput, TInput> action)
 => evaluator(o.Value) ? o : new Maybe <TInput>(action(o.Value));
Exemple #12
0
 public static MonadicValue <TInput> Do <TInput>(this MonadicValue <TInput> o, Action <TInput> action)
 {
     action(o.Value);
     return(o);
 }
Exemple #13
0
 public static MonadicValue <TResult> With <TInput, TResult>(this MonadicValue <TInput> o, Func <TInput, TResult> evaluator)
 => new MonadicValue <TResult>(evaluator(o.Value));
 public static MatcherContext <TV> Match <TV>(this MonadicValue <TV> v) => new MatcherContext <TV>(v);
Exemple #15
0
 public static IEnumerable <MonadicValue <T> > Lift <T>(this MonadicValue <IEnumerable <MonadicValue <T> > > v) => v.Value;
 public static ListMatcherContext <TV> Match <TV>(this MonadicValue <IEnumerable <TV> > v) => new ListMatcherContext <TV>(v);
Exemple #17
0
 public static MonadicValue <T> ToM <T>(this MonadicValue <T> value) => value;
 public static TypeMatcherContext <TV> TypeMatch <TV>(this MonadicValue <TV> v) => new TypeMatcherContext <TV>(v);
Exemple #19
0
 public static MonadicValue <TU> Map <TV, TU>(this MonadicValue <TV> v, Func <MonadicValue <TV>, TU> mapFunc) => mapFunc(v).ToM();
Exemple #20
0
 public static Maybe <T> ToMaybe <T>(this MonadicValue <T> value) => new Maybe <T>(value.Value);
Exemple #21
0
 public Matcher()
 {
     contextValue = null;
 }
Exemple #22
0
 public static Matcher <TV, TU> Match <TV, TU, T1, T2, T3>(this FuncState <T1, T2, T3> s,
                                                           MonadicValue <TV> value, Func <MatcherContext <TV>, Func <Func <T1, T2, T3>, T3>, Matcher <TV, TU> > f) => f(value.Match(), s.Func);
Exemple #23
0
 public Matcher(MonadicValue <TV> contextValue)
 {
     this.contextValue = contextValue;
 }
Exemple #24
0
 public static Matcher <TV, TU> Match <TV, TU, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this FuncState <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> s,
                                                                                        MonadicValue <TV> value, Func <MatcherContext <TV>, Func <Func <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, T10>, Matcher <TV, TU> > f) => f(value.Match(), s.Func);
Exemple #25
0
 public static Result <T> Success <T>(MonadicValue <T> value) => new Result <T>(true, value.Value);
 public ListMatcher(MonadicValue <IEnumerable <TV> > contextValue) : base(contextValue)
 {
 }
 public PartiaMatcher(MonadicValue <TV> contextValue, Func <T1, TV, bool> func) : base(contextValue)
 {
     _func = func;
 }