Esempio n. 1
0
        /// <summary>
        /// Init new Logs Storage for logger using CollectDetailsSettings
        /// </summary>
        public static Lst I(this Lst CurrLogsStorage, Sld CollectDetailsSettings)
        {
            var r = CurrLogsStorage;

            r.S = CollectDetailsSettings;

            if (r.S != null && r.S.S != null)
            {
                r.C = new List <Mx>();
                r.X = new List <Cx>();
                r.E = new List <Err>();
                r.I = new List <Inf>();

                var s = r.S.S;
                if (s.En == true)
                {
                    r.En = new List <Env>();
                }
                if (s.P == true)
                {
                    r.P = new List <Prf>();
                }
                if (s.Pr == true)
                {
                    r.Pr = new List <Prc>();
                }
                if (s.Pp == true)
                {
                    r.Pd = new List <Prd>();
                }
                if (s.Hr == true)
                {
                    r.Hr = new List <Hrq>();
                }
                if (s.Hs == true)
                {
                    r.Hs = new List <Hsl>();
                }
                if (s.Hc == true)
                {
                    r.Hc = new List <Hcx>();
                }
                if (s.Wp == true)
                {
                    r.Wp = new List <Wpl>();
                }
                if (s.Wr == true)
                {
                    r.Wpr = new List <Wpr>();
                }
                if (s.B == true)
                {
                    r.Hb = new List <Hbc>();
                }
                if (s.U == true)
                {
                    r.Wi = new List <Wil>();
                }
            }

            return(CurrLogsStorage);
        }
Esempio n. 2
0
 /// <summary>
 /// Remove Tag from Contacts
 /// </summary>
 /// <param name="ids">ids</param>
 /// <param name="tagId">tagId</param>
 /// <returns><see cref="Unit"/></returns>
 public static InfusioOp <Unit> RemoveTagFromContactIds(Lst <long> ids, long tagId) =>
 new InfusioOp <Unit> .RemoveTagFromContactIds(Return, ids, tagId);
Esempio n. 3
0
 public EnumModel(string name = default, Lst <string> values = default, string description = default)
 {
     Name        = name;
     Values      = values;
     Description = description;
 }
Esempio n. 4
0
 private void arrived(Floor floor, Buffer<Action> b)
 {
     Now = floor.mNum;
       if (Stops.Null()) {
     b.Put(Action.Wait);
     return;
       }
       if (Stops.Hd() == Now) {
     Stops = Stops.Tl();
     b.Put(Action.Stop);
     foreach (Person p in mPeople) { p.Stopped(floor); };
     return;
       }
       if (Stops.Hd() > Now) {
     b.Put(Action.Up);
     return;
       }
       if (Stops.Hd() < Now) {
     b.Put(Action.Down);
     return;
       }
 }
Esempio n. 5
0
 /// <summary>
 /// Retrieve File
 /// </summary>
 /// <param name="fileId">fileId</param>
 /// <param name="optionalProperties">Comma-delimited list of File properties to include in the response. (Some fields such as `file_data` aren't included, by default.)</param>
 /// <returns><see cref="FileInformation"/></returns>
 public static InfusioOp <FileInformation> GetFile(long fileId, Lst <string> optionalProperties = default) =>
 new InfusioOp <FileInformation> .GetFile(Return, fileId, optionalProperties);
Esempio n. 6
0
 public static Lst <Monomial> Substitute(Monomial monomial, Lst <Subst> substs, Style style)
 {
     return(Monomial.Product(new Monomial(monomial.coefficient, style), Substitute(monomial.factors, substs, style), style));
 }
 private GenLanguageDefIO(
     string commentStart,
     string commentEnd,
     string commentLine,
     bool nestedComments,
     Parser<char, char> identStart,
     Parser<char, char> identLetter,
     Parser<char, char> opStart,
     Parser<char, char> opLetter,
     Lst<string> reservedNames,
     Lst<string> reservedOpNames,
     bool caseSensitive
     )
 {
     CommentStart = commentStart;
     CommentEnd = commentEnd;
     CommentLine = commentLine;
     NestedComments = nestedComments;
     IdentStart = identStart;
     IdentLetter = identLetter;
     OpStart = opStart;
     OpLetter = opLetter;
     ReservedNames = reservedNames.OrderBy(x => x).Freeze();
     ReservedOpNames = reservedOpNames.OrderBy(x=> x).Freeze();
     CaseSensitive = caseSensitive;
 }
Esempio n. 8
0
 private Time WaitTime(Dir dir, FloorNum floor, FloorNum now, Lst<FloorNum> stop)
 {
     return WaitTime(dir, floor, now, 0, stop);
 }
Esempio n. 9
0
 private Time WaitTime(Dir dir, FloorNum floor, FloorNum now, Time t, Lst<FloorNum> stops)
 {
     if (stops.Null()) { return t + Math.Abs(floor - now); }
       FloorNum next = stops.Hd();
       Lst<FloorNum> after = stops.Tl();
       if (floor == next) { return t + Math.Abs(floor - now); }
       if (dir == Dir.Up && now <= floor && floor <= next) { return t + floor - now; }
       if (dir == Dir.Down && now >= floor && floor >= next) { return t + now - floor; }
       return WaitTime(dir, floor, next, t + Math.Abs(now - next) + StopTime, after);
 }
Esempio n. 10
0
 private Lst<FloorNum> StopAt(FloorNum floor, FloorNum now, Lst<FloorNum> stops)
 {
     return StopAt(floor, Lst<FloorNum>.nil, stops.Cons(now)).Tl(); //NB: we take the tail to avoid restopping at now.
 }
Esempio n. 11
0
 private Lst<FloorNum> StopAt(FloorNum floor, Lst<FloorNum> before, Lst<FloorNum> stops)
 {
     if (stops.Null()) { return before.Cons(floor).Reverse(); }
       if (floor == stops.Hd()) { return before.ReverseAppend(stops); }
       if (!stops.Tl().Null()) {
     FloorNum X = stops.Hd(); FloorNum Y = stops.Tl().Hd(); Lst<FloorNum> afterXY = stops.Tl().Tl();
     if (X < floor && floor < Y) { return before.ReverseAppend(afterXY.Cons(Y).Cons(floor).Cons(X)); }
     if (Y < floor && floor < X) { return before.ReverseAppend(afterXY.Cons(Y).Cons(floor).Cons(X)); }
       }
       return StopAt(floor, before.Cons(stops.Hd()), stops.Tl());
 }
Esempio n. 12
0
 private Lst<FloorNum> Insert(Dir dir, FloorNum floor, FloorNum now, Lst<FloorNum> before, Lst<FloorNum> stop)
 {
     if (stop.Null()) { return before.Cons(floor).Reverse(); }
       FloorNum next = stop.Hd();
       Lst<FloorNum> after = stop.Tl();
       if (floor == next) { return before.ReverseAppend(stop); }
       if (floor == now) { return before.ReverseAppend(stop); }
       if (dir == Dir.Up && now < floor && floor < next) { return before.ReverseAppend(stop.Cons(floor)); }
       if (dir == Dir.Down && next < floor && floor < now) { return before.ReverseAppend(stop.Cons(floor)); }
       return Insert(dir, floor, next, before.Cons(next), after);
 }
Esempio n. 13
0
 private Lst<FloorNum> Insert(Dir dir, FloorNum floor, FloorNum now, Lst<FloorNum> stop)
 {
     return Insert(dir, floor, now, new Nil<FloorNum>(), stop);
 }
Esempio n. 14
0
 private void howLong(FloorNum floor, Dir dir, Buffer<WaitTime> b)
 {
     Time t = WaitTime(dir, floor, Now, Stops);
       Reservation reservation = new Reservation();
       b.Put(new WaitTime(t, reservation));
       if (reservation.Get()) {
     Stops = Insert(dir, floor, Now, Stops);
       }
 }
Esempio n. 15
0
 public Either <string, TestsMatchResult> MatchTestRuns(Lst <TestBuildResult> oldTestResults, Lst <TestBuildResult> newTestResults)
 {
     return(new TestsMatchResult {
         NewTestResults = newTestResults,
         OldTestResults = oldTestResults,
         OnlyNewTestResults = newTestResults
                              .Map(testBuildResult => new TestBuildResult {
             BuildName = testBuildResult.BuildName,
             TestResults = oldTestResults.Find(oldBuildResult => oldBuildResult.BuildName == testBuildResult.BuildName).Match(
                 Some: oldBuildresult => testBuildResult.TestResults.Filter(
                     buildResult => !oldBuildresult.TestResults.Exists(oldTestResult => oldTestResult.Name == buildResult.Name)),
                 None: () => testBuildResult.TestResults).Apply(AddTestDetails)
         })
     });
 }
Esempio n. 16
0
 public MB BindAsync <MONADB, MB, B>(Lst <A> ma, Func <A, MB> f) where MONADB : struct, MonadAsync <Unit, Unit, MB, B> =>
 traverseSyncAsync <MLst <A>, MONADB, Lst <A>, MB, A, B>(ma, f);
Esempio n. 17
0
 // substitute x with (x+ - x-) in a flow that is already in polynomial form as a result of Polynomize
 public static Lst <Polynomize.PolyODE> Substitute(Lst <Polynomize.PolyODE> odes, Lst <Subst> substs, Style style)
 {
     if (odes is Cons <Polynomize.PolyODE> cons)
     {
         Polynomize.PolyODE ode = cons.head;
         Subst subst            = Lookup(ode.var, substs);
         if (subst == null)
         {
             return(new Cons <Polynomize.PolyODE>(new Polynomize.PolyODE(ode.var, Substitute(ode.poly, substs, style), ode.split),
                                                  Substitute(cons.tail, substs, style)));
         }
         else     // this should never happen because we split ODEs in PositivizeODEs
         {
             throw new Error("Polynomize.Substitute");
             //return
             //     new Cons<Polynomize.PolyODE>(new Polynomize.PolyODE(subst.plus, Substitute(ode.poly, substs, style)),
             //        new Cons<Polynomize.PolyODE>(new Polynomize.PolyODE(subst.minus, Substitute(ode.poly, substs, style)),
             //            Substitute(cons.tail, substs, style)));
         }
     }
     else
     {
         return(Polynomize.PolyODE.nil);
     }
 }
Esempio n. 18
0
 public Func <Unit, int> Count(Lst <A> fa) => _ =>
 fa.Count();
Esempio n. 19
0
        // ===== Rename =====

        // rename variables x (a subset of the ode variables) to x⁰ in odes
        public static (Lst <Polynomize.PolyODE> renOdes, Lst <Polynomize.Equation> renEqs, Dictionary <Symbol, SpeciesFlow> dict) Rename(Lst <SpeciesFlow> vars, Lst <Polynomize.PolyODE> odes, Lst <Polynomize.Equation> eqs, Style style)
        {
            Dictionary <Symbol, SpeciesFlow> dict = new Dictionary <Symbol, SpeciesFlow>();

            if (vars is Nil <SpeciesFlow> )
            {
                return(odes, eqs, dict);
            }
            vars.Each(var => { dict.Add(var.species, new SpeciesFlow(new Symbol(var.species.Format(style) + "⁰"))); });
            return(Rename(dict, odes, style), Rename(dict, eqs, style), dict);
        }
Esempio n. 20
0
 public Lst <A> Subtract(Lst <A> x, Lst <A> y) =>
 Enumerable.Except(x, y).Freeze();
Esempio n. 21
0
        public Types()
        {
            Int = new TypeDef(
                "int",
                typeof(int),
                p => from x in p.integer
                     select (object)x,
                list => list.Map(x => (int)x),
                map => map.Map(x => (int)x),
                Map(
                    OpT("+", () => Int, (lhs, rhs) => (int)lhs + (int)rhs),
                    OpT("-", () => Int, (lhs, rhs) => (int)lhs - (int)rhs),
                    OpT("*", () => Int, (lhs, rhs) => (int)lhs * (int)rhs),
                    OpT("/", () => Int, (lhs, rhs) => (int)lhs / (int)rhs),
                    OpT("%", () => Int, (lhs, rhs) => (int)lhs % (int)rhs),
                    Op("!=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (int)lhs.Value != (int)rhs.Value)),
                    Op("==", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (int)lhs.Value == (int)rhs.Value)),
                    Op("<", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (int)lhs.Value < (int)rhs.Value)),
                    Op("<=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (int)lhs.Value <= (int)rhs.Value)),
                    Op(">", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (int)lhs.Value > (int)rhs.Value)),
                    Op(">=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (int)lhs.Value >= (int)rhs.Value)),
                    OpT("^", () => Int, (lhs, rhs) => Math.Pow((int)lhs, (int)rhs)),
                    OpT("&", () => String, (lhs, rhs) => ((int)lhs & (int)rhs)),
                    OpT("|", () => String, (lhs, rhs) => ((int)lhs | (int)rhs))

                ),
                Map(
                    OpT("+", () => Int, rhs => +(int)rhs),
                    OpT("-", () => Int, rhs => -(int)rhs)
                ),
                null,
                Map(
                    Conv("float", obj => (int)((double)obj)),
                    Conv("process-flags", obj => (int)((ProcessFlags)obj))
                ),
                null,
                2
            );

            Double = new TypeDef(
                "float",
                typeof(double),
                p => from x in p.floating
                     select (object)x,
                list => list.Map(x => (double)x),
                map => map.Map(x => (double)x),
                Map(
                    OpT("+", () => Int, (lhs, rhs) => (double)lhs + (double)rhs),
                    OpT("-", () => Int, (lhs, rhs) => (double)lhs - (double)rhs),
                    OpT("*", () => Int, (lhs, rhs) => (double)lhs * (double)rhs),
                    OpT("/", () => Int, (lhs, rhs) => (double)lhs / (double)rhs),
                    Op("!=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (double)lhs.Value != (double)rhs.Value)),
                    Op("==", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (double)lhs.Value == (double)rhs.Value)),
                    Op("<", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (double)lhs.Value < (double)rhs.Value)),
                    Op("<=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (double)lhs.Value <= (double)rhs.Value)),
                    Op(">", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (double)lhs.Value > (double)rhs.Value)),
                    Op(">=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (double)lhs.Value >= (double)rhs.Value)),
                    OpT("^", () => Int, (lhs, rhs) => Math.Pow((double)lhs, (double)rhs))
                ),
                Map(
                    OpT("+", () => Int, rhs => +(double)rhs),
                    OpT("-", () => Int, rhs => -(double)rhs)
                ),
                null,
                Map(
                    Conv("int", obj => (double)((int)obj))
                ),
                null,
                1
            );

            Bool = new TypeDef(
                "bool",
                typeof(bool),
                p => from v in choice(
                        p.reserved("true"),
                        p.reserved("false"))
                     select (object)(v == "true"),
                list => list.Map(x => (bool)x),
                map => map.Map(x => (bool)x),
                Map(
                    OpT("!=", () => Bool, (lhs, rhs) => (bool)lhs != (bool)rhs),
                    OpT("==", () => Bool, (lhs, rhs) => (bool)lhs == (bool)rhs),
                    OpT("&&", () => Bool, (lhs, rhs) => (bool)lhs && (bool)rhs),
                    OpT("||", () => Bool, (lhs, rhs) => (bool)lhs || (bool)rhs)
                ),
                Map(
                    OpT("!", () => Int, rhs => !(bool)rhs)
                ),
                null,
                null,
                null,
                0
            );

            String = new TypeDef(
                "string",
                typeof(string),
                p => from _ in unitp
                     from v in p.stringLiteral
                     select (object)v,
                list => list.Map(x => (string)x),
                map => map.Map(x => (string)x),
                Map(
                    OpT("+", () => String, (lhs, rhs) => (string)lhs + (string)rhs),
                    Op("==", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (string)lhs.Value == (string)rhs.Value)),
                    Op("!=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (string)lhs.Value != (string)rhs.Value)),
                    Op(">=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((string)lhs.Value).CompareTo((string)rhs.Value) >= 0)),
                    Op("<=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((string)lhs.Value).CompareTo((string)rhs.Value) <= 0)),
                    Op(">", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((string)lhs.Value).CompareTo((string)rhs.Value) > 0)),
                    Op("<", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((string)lhs.Value).CompareTo((string)rhs.Value) < 0))
                ),
                Map(
                    OpT("!", () => Int, rhs => !(bool)rhs)
                ),
                null,
                Map(
                    Conv("int", obj => obj.ToString()),
                    Conv("float", obj => obj.ToString()),
                    Conv("bool", obj => obj.ToString()),
                    Conv("process-id", obj => obj.ToString()),
                    Conv("process-name", obj => obj.ToString()),
                    Conv("process-flags", obj => obj.ToString()),
                    Conv("time", obj => obj.ToString()),
                    Conv("directive", obj => obj.ToString()),
                    Conv("message-directive", obj => obj.ToString()),
                    Conv("disp", obj => obj.ToString())
                ),
                null,
                0
            );

            ProcessId = new TypeDef(
                "process-id",
                typeof(ProcessId),
                p => from v in p.processId
                     select (object)v,
                list => list.Map(x => (ProcessId)x),
                map => map.Map(x => (ProcessId)x),
                Map(
                    OpT("+", () => String, (lhs, rhs) => ((ProcessId)lhs).Append((ProcessId)rhs)),
                    Op("==", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (ProcessId)lhs.Value == (ProcessId)rhs.Value)),
                    Op("!=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (ProcessId)lhs.Value != (ProcessId)rhs.Value)),
                    Op(">=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((ProcessId)lhs.Value).CompareTo((ProcessId)rhs.Value) >= 0)),
                    Op("<=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((ProcessId)lhs.Value).CompareTo((ProcessId)rhs.Value) <= 0)),
                    Op(">", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((ProcessId)lhs.Value).CompareTo((ProcessId)rhs.Value) > 0)),
                    Op("<", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((ProcessId)lhs.Value).CompareTo((ProcessId)rhs.Value) < 0))
                ),
                null,
                null,
                Map(
                    Conv("process-name", obj => new ProcessId("/"+((ProcessName)obj).Value)),
                    Conv("string", obj => new ProcessId((string)obj))
                ),
                null,
                10
            );

            ProcessName = new TypeDef(
                "process-name",
                typeof(ProcessName),
                p => from _ in unitp
                     from v in p.processName
                     select (object)v,
                list => list.Map(x => (ProcessName)x),
                map => map.Map(x => (ProcessName)x),
                Map(
                    Op("==", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (ProcessName)lhs.Value == (ProcessName)rhs.Value)),
                    Op("!=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (ProcessName)lhs.Value != (ProcessName)rhs.Value)),
                    Op(">=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((ProcessName)lhs.Value).CompareTo((ProcessName)rhs.Value) >= 0)),
                    Op("<=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((ProcessName)lhs.Value).CompareTo((ProcessName)rhs.Value) <= 0)),
                    Op(">", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((ProcessName)lhs.Value).CompareTo((ProcessName)rhs.Value) > 0)),
                    Op("<", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((ProcessName)lhs.Value).CompareTo((ProcessName)rhs.Value) < 0))
                ),
                null,
                null,
                Map(
                    Conv("string", obj => new ProcessName((string)obj))
                ),
                null,
                10
            );

            Func<ProcessSystemConfigParser, string, ProcessFlags, Parser<ProcessFlags>> flagMap =
                (p, name, flags) =>
                    attempt(
                    from x in p.reserved(name)
                    select flags);

            Func<ProcessSystemConfigParser, Parser<ProcessFlags>> flag =
                p =>
                    choice(
                        flagMap(p, "default", LanguageExt.ProcessFlags.Default),
                        flagMap(p, "listen-remote-and-local", LanguageExt.ProcessFlags.ListenRemoteAndLocal),
                        flagMap(p, "persist-all", LanguageExt.ProcessFlags.PersistAll),
                        flagMap(p, "persist-inbox", LanguageExt.ProcessFlags.PersistInbox),
                        flagMap(p, "persist-state", LanguageExt.ProcessFlags.PersistState),
                        flagMap(p, "remote-publish", LanguageExt.ProcessFlags.RemotePublish),
                        flagMap(p, "remote-state-publish", LanguageExt.ProcessFlags.RemoteStatePublish));

            Func<ProcessSystemConfigParser, Parser<ProcessFlags>> flagsValue =
                p =>
                    from fs in p.brackets(p.commaSep(flag(p)))
                    select List.fold(fs, LanguageExt.ProcessFlags.Default, (s, x) => s | x);

            ProcessFlags = new TypeDef(
                "process-flags",
                typeof(ProcessFlags),
                p => from v in flagsValue(p)
                     select (object)v,
                list => list.Map(x => (ProcessFlags)x),
                map => map.Map(x => (ProcessFlags)x),
                Map(
                    Op("==", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (ProcessFlags)lhs.Value == (ProcessFlags)rhs.Value)),
                    Op("!=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (ProcessFlags)lhs.Value != (ProcessFlags)rhs.Value)),
                    Op(">=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((ProcessFlags)lhs.Value).CompareTo((ProcessFlags)rhs.Value) >= 0)),
                    Op("<=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((ProcessFlags)lhs.Value).CompareTo((ProcessFlags)rhs.Value) <= 0)),
                    Op(">", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((ProcessFlags)lhs.Value).CompareTo((ProcessFlags)rhs.Value) > 0)),
                    Op("<", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((ProcessFlags)lhs.Value).CompareTo((ProcessFlags)rhs.Value) < 0)),
                    OpT("&", () => String, (lhs, rhs) => ((ProcessFlags)lhs & (ProcessFlags)rhs)),
                    OpT("|", () => String, (lhs, rhs) => ((ProcessFlags)lhs | (ProcessFlags)rhs))
                ),
                Map(
                    OpT("~", () => String, rhs => ~(ProcessFlags)rhs)
                ),
                null,
                Map(
                    Conv("int", obj => (ProcessFlags)((int)obj))
                ),
                null,
                10
            );

            Func<ProcessSystemConfigParser, Parser<string>> timeUnit =
                p =>
                    choice(
                        attempt(p.reserved("seconds")),
                        attempt(p.reserved("second")),
                        attempt(p.reserved("secs")),
                        attempt(p.reserved("sec")),
                        attempt(p.reserved("s")),
                        attempt(p.reserved("minutes")),
                        attempt(p.reserved("minute")),
                        attempt(p.reserved("mins")),
                        attempt(p.reserved("min")),
                        attempt(p.reserved("milliseconds")),
                        attempt(p.reserved("millisecond")),
                        attempt(p.reserved("ms")),
                        attempt(p.reserved("hours")),
                        attempt(p.reserved("hour")),
                        p.reserved("hr"))
                       .label("Unit of time (e.g. seconds, mins, hours, hr, sec, min...)");

            Func<ProcessSystemConfigParser, Parser<Time>> timeValue =
                p =>
                    from v in p.floating
                    from u in timeUnit(p)
                    from r in TimeAttr.TryParse(v, u).Match(
                        Some: result,
                        None: () => failure<Time>("Invalid unit of time"))
                    select r;

            Time = new TypeDef(
                "time",
                typeof(Time),
                p => from v in p.token(timeValue(p))
                     select (object)v,
                list => list.Map(x => (Time)x),
                map => map.Map(x => (Time)x),
                Map(
                    OpT("+", () => String, (lhs, rhs) => ((Time)lhs + (Time)rhs)),
                    OpT("-", () => String, (lhs, rhs) => ((Time)lhs - (Time)rhs)),
                    Op("==", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (Time)lhs.Value == (Time)rhs.Value)),
                    Op("!=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (Time)lhs.Value != (Time)rhs.Value)),
                    Op(">=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((Time)lhs.Value).CompareTo((Time)rhs.Value) >= 0)),
                    Op("<=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((Time)lhs.Value).CompareTo((Time)rhs.Value) <= 0)),
                    Op(">", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((Time)lhs.Value).CompareTo((Time)rhs.Value) > 0)),
                    Op("<", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, ((Time)lhs.Value).CompareTo((Time)rhs.Value) < 0))
                ),
                Map(
                    OpT("+", () => Int, rhs => 0.Seconds() + (Time)rhs),
                    OpT("-", () => Int, rhs => 0.Seconds() - (Time)rhs)
                ),
                null,
                null,
                null,
                0
            );

            Func<ProcessSystemConfigParser, Parser<MessageDirective>> fwdToSelf =
                p =>
                    from _ in p.reserved("forward-to-self")
                    select new ForwardToSelf() as MessageDirective;

            Func<ProcessSystemConfigParser, Parser<MessageDirective>> fwdToParent =
                p =>
                    from _ in p.reserved("forward-to-parent")
                    select new ForwardToParent() as MessageDirective;

            Func<ProcessSystemConfigParser, Parser<MessageDirective>> fwdToDeadLetters =
                p =>
                    from _ in p.reserved("forward-to-dead-letters")
                    select new ForwardToDeadLetters() as MessageDirective;

            Func<ProcessSystemConfigParser, Parser<MessageDirective>> stayInQueue =
                p =>
                    from _ in p.reserved("stay-in-queue")
                    select new StayInQueue() as MessageDirective;

            Func<ProcessSystemConfigParser, Parser<MessageDirective>> fwdToProcess =
                p =>
                    from _ in p.reserved("forward-to-process")
                    from pid in attempt(p.expr(ProcessId)).label("'forward-to-process <ProcessId>'")
                    select new ForwardToProcess((ProcessId)pid.Value) as MessageDirective;

            Func<ProcessSystemConfigParser, Parser<MessageDirective>> msgDirective =
                p =>
                    choice(
                        fwdToDeadLetters(p),
                        fwdToSelf(p),
                        fwdToParent(p),
                        fwdToProcess(p),
                        stayInQueue(p));

            MessageDirective = new TypeDef(
                "message-directive",
                typeof(MessageDirective),
                p => from v in p.token(msgDirective(p))
                     select (object)v,
                list => list.Map(x => (MessageDirective)x),
                map => map.Map(x => (MessageDirective)x),
                Map(
                    Op("==", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (MessageDirective)lhs.Value == (MessageDirective)rhs.Value)),
                    Op("!=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (MessageDirective)lhs.Value != (MessageDirective)rhs.Value))
                ),
                null,
                null,
                null,
                null,
                10
            );

            Func<ProcessSystemConfigParser, Parser<Directive>> directive =
                p =>
                    choice(
                        p.reserved("resume").Map(_ => LanguageExt.Directive.Resume),
                        p.reserved("restart").Map(_ => LanguageExt.Directive.Restart),
                        p.reserved("stop").Map(_ => LanguageExt.Directive.Stop),
                        p.reserved("escalate").Map(_ => LanguageExt.Directive.Escalate));

            Directive = new TypeDef(
                "directive",
                typeof(Directive),
                p => from v in p.token(directive(p))
                     select (object)v,
                list => list.Map(x => (Directive)x),
                map => map.Map(x => (Directive)x),
                Map(
                    Op("==", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (Directive)lhs.Value == (Directive)rhs.Value)),
                    Op("!=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (Directive)lhs.Value != (Directive)rhs.Value))
                ),
                null,
                null,
                null,
                null,
                10
            );

            Func<ProcessSystemConfigParser, Parser<string>> dispType =
                p =>
                    choice(
                        p.reserved("broadcast"),
                        attempt(p.reserved("least-busy")),
                        attempt(p.reserved("round-robin")),
                        p.reserved("random"),
                        p.reserved("hash"),
                        p.reserved("first"),
                        p.reserved("second"),
                        p.reserved("third"),
                        p.reserved("last")
                    );

            DispatcherType = new TypeDef(
                "disp",
                typeof(string),
                p => from v in p.token(dispType(p))
                     select (object)v,
                list => list.Map(x => (string)x),
                map => map.Map(x => (string)x),
                Map(
                    Op("==", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (string)lhs.Value == (string)rhs.Value)),
                    Op("!=", (ValueToken lhs, ValueToken rhs) => new ValueToken(Bool, (string)lhs.Value != (string)rhs.Value))
                ),
                null,
                null,
                null,
                null,
                10
            );

            TypeMap = Map.create(
                Tuple(typeof(bool).FullName, Bool),
                Tuple(typeof(int).FullName, Int),
                Tuple(typeof(double).FullName, Double),
                Tuple(typeof(string).FullName, String),
                Tuple(typeof(ProcessId).FullName, ProcessId),
                //Tuple(typeof(ProcessName).FullName, ProcessName),
                Tuple(typeof(ProcessFlags).FullName, ProcessFlags),
                Tuple(typeof(Time).FullName, Time),
                Tuple(typeof(MessageDirective).FullName, MessageDirective),
                Tuple(typeof(Directive).FullName, Directive)
            );

            All = Map.create(
                Tuple(Bool.Name, Bool),
                Tuple(Int.Name, Int),
                Tuple(Double.Name, Double),
                Tuple(String.Name, String),
                Tuple(ProcessId.Name, ProcessId),
                //Tuple(ProcessName.Name, ProcessName),
                Tuple(ProcessFlags.Name, ProcessFlags),
                Tuple(Time.Name, Time),
                Tuple(MessageDirective.Name, MessageDirective),
                Tuple(Directive.Name, Directive),
                Tuple(DispatcherType.Name, DispatcherType)
                );
            AllInOrder = (from x in All.Values
                          orderby x.Order descending
                          select x)
                         .Freeze();
        }
Esempio n. 22
0
 public bool Equals(Lst <A> x, Lst <A> y) =>
 Enumerable.SequenceEqual(x, y);
Esempio n. 23
0
 /// <summary>
 /// Retrieve a Contact
 /// </summary>
 /// <param name="id">id</param>
 /// <param name="optionalProperties">Comma-delimited list of Contact properties to include in the response. (Some fields such as `lead_source_id`, `custom_fields`, and `job_title` aren't included, by default.)</param>
 /// <returns><see cref="FullContact"/></returns>
 public static InfusioOp <FullContact> GetContact(long id, Lst <string> optionalProperties = default) =>
 new InfusioOp <FullContact> .GetContact(Return, id, optionalProperties);
Esempio n. 24
0
 public Func <Unit, S> FoldBack <S>(Lst <A> fa, S state, Func <S, A, S> f) => _ =>
 fa.FoldBack(state, f);
Esempio n. 25
0
 /// <summary>
 /// Retrieve an Opportunity
 /// </summary>
 /// <param name="opportunityId">opportunityId</param>
 /// <param name="optionalProperties">Comma-delimited list of Opportunity properties to include in the response. (Some fields such as `custom_fields` aren't included, by default.)</param>
 /// <returns><see cref="Opportunity"/></returns>
 public static InfusioOp <Opportunity> GetOpportunity(long opportunityId, Lst <string> optionalProperties = default) =>
 new InfusioOp <Opportunity> .GetOpportunity(Return, opportunityId, optionalProperties);
Esempio n. 26
0
 public Lst <A> Plus(Lst <A> ma, Lst <A> mb) =>
 ma + mb;
 public static Schedule ToSchedule(this Lst <Duration> list) =>
 Schedule.TimeSeries(list);
Esempio n. 28
0
 public int GetHashCode(Lst <A> x) =>
 x.GetHashCode();
Esempio n. 29
0
 private Cursor(Lst <BranchTag> keys, Key finalKey)
 {
     Keys     = keys;
     FinalKey = finalKey;
 }
Esempio n. 30
0
 static int Product(Lst <NonEmpty, int> list) =>
 list.Fold(1, (s, x) => s * x);
Esempio n. 31
0
        public static Lst <Option <B> > LstTBind <A, B>(Lst <Option <A> > list, Func <A, Option <B> > bind)
        {
            var LstT = default(Trans <MLst <Option <A> >, Lst <Option <A> >, MOption <A>, Option <A>, A>);

            return(LstT.Bind <MLst <Option <B> >, Lst <Option <B> >, MOption <B>, Option <B>, B>(list, bind));
        }
Esempio n. 32
0
 public string Divify(Lst <NonEmpty, NonNullItems <string>, string> items) =>
 String.Join("", items.Map(x => $"<div>{x}</div>"));
 public KzFieldValidationRules(int fieldNumber, Lst <KzFieldValidationRule> rules)
 {
     this.FieldNumber = fieldNumber;
     this.Rules       = rules;
 }
Esempio n. 34
0
 public int GetHashCode(Lst <A> x) =>
 hash <HashA, A>(x);
Esempio n. 35
0
 public static Polynomial Substitute(Polynomial polynomial, Lst <Subst> substs, Style style)
 {
     return(new Polynomial(Substitute(polynomial.monomials, substs, style)));
 }
Esempio n. 36
0
 public Task <int> GetHashCodeAsync(Lst <A> x) =>
 GetHashCode(x).AsTask();
Esempio n. 37
0
 public static Lst <Polynomize.Equation> Substitute(Lst <Polynomize.Equation> eqs, Lst <Subst> substs, Style style)
 {
     if (eqs is Cons <Polynomize.Equation> cons)
     {
         Polynomize.Equation eq   = cons.head;
         Lst <Monomial>[]    args = new Lst <Monomial> [eq.args.Length];
         for (int i = 0; i < eq.args.Length; i++)
         {
             args[i] = Substitute(eq.args[i], substs, style);
         }
         Subst subst = Lookup(eq.var, substs);
         if (subst == null)
         {
             return
                 (new Cons <Polynomize.Equation>(new Polynomize.Equation(eq.var, eq.op, args, eq.splitOp),
                                                 Substitute(cons.tail, substs, style)));
         }
         else
         {
             return
                 (new Cons <Polynomize.Equation>(new Polynomize.Equation(subst.plus, eq.op, args, splitOp: Polynomize.Split.Pos),
                                                 new Cons <Polynomize.Equation>(new Polynomize.Equation(subst.minus, eq.op, args, splitOp: Polynomize.Split.Neg),
                                                                                Substitute(cons.tail, substs, style))));
         }
     }
     else
     {
         return(Polynomize.Equation.nil);
     }
 }
Esempio n. 38
0
 public KzFieldFormValidationError(Lst <KzFieldValidationError> errors)
 {
     this.Errors = errors;
 }
 public GenLanguageDefIO With(
     string CommentStart = null,
     string CommentEnd = null,
     string CommentLine = null,
     bool? NestedComments = null,
     Parser<char, char> IdentStart = null,
     Parser<char, char> IdentLetter = null,
     Parser<char, char> OpStart = null,
     Parser<char, char> OpLetter = null,
     Lst<string> ReservedNames = null,
     Lst<string> ReservedOpNames = null,
     bool? CaseSensitive = null
     ) =>
     new GenLanguageDefIO(
         CommentStart == null ? this.CommentStart : CommentStart,
         CommentEnd == null ? this.CommentEnd : CommentEnd,
         CommentLine == null ? this.CommentLine : CommentLine,
         NestedComments == null ? this.NestedComments : NestedComments.Value,
         IdentStart == null ? this.IdentStart : IdentStart,
         IdentLetter == null ? this.IdentLetter : IdentLetter,
         OpStart == null ? this.OpStart : OpStart,
         OpLetter == null ? this.OpLetter : OpLetter,
         ReservedNames == null ? this.ReservedNames : ReservedNames,
         ReservedOpNames == null ? this.ReservedOpNames : ReservedOpNames,
         CaseSensitive == null ? this.CaseSensitive : CaseSensitive.Value
     );
Esempio n. 40
0
 /// <summary>
 /// Retrieve a Campaign
 /// </summary>
 /// <param name="campaignId">campaignId</param>
 /// <param name="optionalProperties">Comma-delimited list of Campaign properties to include in the response. (The fields `goals` and `sequences` aren't included, by default.)</param>
 /// <returns><see cref="Campaign"/></returns>
 public static InfusioOp <Campaign> GetCampaign(long campaignId, Lst <string> optionalProperties = default) =>
 new InfusioOp <Campaign> .GetCampaign(Return, campaignId, optionalProperties);
Esempio n. 41
0
 public Unit Register(TypeDef type)
 {
     All = All.Add(type.Name, type);
     AllInOrder = (from x in All.Values
                   orderby x.Order descending
                   select x)
                  .Freeze();
     return unit;
 }
Esempio n. 42
0
 /// <summary>
 /// List Companies
 /// </summary>
 /// <param name="optionalProperties">Comma-delimited list of Company properties to include in the response. (Fields such as `notes`, `fax_number` and `custom_fields` aren't included, by default.)</param>
 /// <param name="orderDirection">How to order the data i.e. ascending (A-Z) or descending (Z-A)</param>
 /// <param name="order">Attribute to order items by</param>
 /// <param name="companyName">Optional company name to query on</param>
 /// <param name="offset">Sets a beginning range of items to return</param>
 /// <param name="limit">Sets a total of items to return</param>
 /// <returns><see cref="CompanyList"/></returns>
 public static InfusioOp <CompanyList> ListCompanies(Lst <string> optionalProperties = default, string orderDirection = default, string order = default, string companyName = default, int offset = default, int limit = default) =>
 new InfusioOp <CompanyList> .ListCompanies(Return, optionalProperties, orderDirection, order, companyName, offset, limit);
Esempio n. 43
0
 public ValueVector(long time, Lst<object> root)
 {
     Time = time;
     Vector = root;
 }
Esempio n. 44
0
        public Lift(int num)
        {
            mNum = num;

              join.Initialize(out HowLong);
              join.Initialize(out Arrived);
              join.Initialize(out Stop);
              join.Initialize(out PersonArrived);
              join.Initialize(out PersonDeparted);

              join.When(ProcessMessage).And(HowLong).Do(delegate(Pair<Pair<FloorNum, Dir>, Buffer<WaitTime>> p)
              {
            howLong(p.Fst.Fst, p.Fst.Snd, p.Snd);
              });

              join.When(ProcessMessage).And(Arrived).Do(delegate(Pair<Floor, Buffer<Action>> p)
              {
            UnderViewLock(delegate
            {
              mStopButtonBackColors[p.Fst.mNum] = Color.Silver;
            });
            arrived(p.Fst, p.Snd);
              });

              join.When(ProcessMessage).And(Stop).Do(delegate(FloorNum floor)
              {
            UnderViewLock(delegate
            {
              mStopButtonBackColors[floor] = Color.Yellow;
            });
            Stops = StopAt(floor, Now, Stops);
              });

              join.When(ProcessMessage).And(PersonArrived).Do(delegate(Pair<Person, Ack> p)
              {
            mPeople.Add(p.Fst);
            p.Snd.Send();
              });

              join.When(ProcessMessage).And(PersonDeparted).Do(delegate(Person person)
              {
            mPeople.Remove(person);
              });

              for (int i = 0; i < Program.NUMFLOORS; i++) {
            Button stop = new Button();
            stop.Location = new Point((2 + (1 + 2 * mNum)) * Program.COLUMNWIDTH, (Program.NUMFLOORS - i) * Program.COLUMNHEIGHT);
            stop.Text = i.ToString();
            stop.Size = new Size(Program.COLUMNWIDTH,Program.COLUMNHEIGHT);
            stop.BackColor = Color.Silver;
            int _i = i;
            stop.Click += new EventHandler(delegate { this.Stop(_i); });
            mStopButtons[i] = stop;
            mStopButtonBackColors[i] = Color.Silver;
              }
        }