public IActionResult Index(int year) { Func <string, IDictionary <string, object>, IEnumerable <WorldCupFsharpRepositoryModule.WorldCupDto> > readDataFunc = (s, p) => _postgresConnection.readData <WorldCupFsharpRepositoryModule.WorldCupDto>(s, p); var readData = FuncConvert.FromFunc(readDataFunc); var worldCupFsharpOption = WorldCupFsharpRepositoryModule.findByYear(readData, YearModule.create(year)); if (worldCupFsharpOption.HasValue()) { var worldCupFsharp = worldCupFsharpOption.Value; var worldCupVm = new WorldCupVm { Year = YearModule.value(worldCupFsharp.Year), Host = WorldCupHostModule.value(worldCupFsharp.Host), Winner = CountryModule.value(worldCupFsharp.Winner) }; return(Content(JsonConvert.SerializeObject(worldCupVm), "application/json")); } return(NotFound()); }
Tuple <T, FSharpList <TEvent> > decide_(TState state) { var a = new Accumulator <TEvent, TState>(FuncConvert.FromFunc(_fold), state); var r = decide(a); return(Tuple.Create(r, a.Accumulated)); }
public EquinoxHandler (Func <TState, IEnumerable <TEvent>, TState> fold, ILogger log, IStream <TEvent, TState> stream, int maxAttempts = 3) : base(FuncConvert.FromFunc(fold), log, stream, maxAttempts) { }
public static FsCodec.IEventCodec <TEvent, byte[], object> Create <TEvent>( Func <TEvent, Tuple <string, byte[]> > encode, Func <string, byte[], TEvent> tryDecode) where TEvent : class { return(FsCodec.Codec.Create( FuncConvert.FromFunc(encode), FuncConvert.FromFunc((Func <Tuple <string, byte[]>, FSharpOption <TEvent> >)TryDecodeImpl))); FSharpOption <TEvent> TryDecodeImpl(Tuple <string, byte[]> encoded) => OptionModule.OfObj(tryDecode(encoded.Item1, encoded.Item2)); }
private Sql.DmlDdlSqlStatement BuildStatement(string query, InputStringNormalizer stringNormalizer) { query = stringNormalizer.InputForLexer; var lexbuf = LexBuffer <char> .FromString(query); Func <LexBuffer <char>, SqlParser.token> func = (x) => SqlLexer.tokenize(x); return(SqlParser.startCT(FuncConvert.FromFunc(func), lexbuf)); }
public IViewBuilder ContentMultiple(string property, IEnumerable <Types.IView> content) { var getter = FSharpValueOption <FSharpFunc <TView, object> > .Some(FuncConvert.FromFunc <TView, object>(control => control.Children)); var setter = FSharpValueOption <FSharpFunc <Tuple <TView, object>, Unit> > .None; var list = Microsoft.FSharp.Collections.ListModule.OfSeq(content); Attrs.Add(Avalonia.FuncUI.Builder.AttrBuilder <TView> .CreateContentMultiple(property, getter, setter, list)); return(this); }
public static Equinox.UnionCodec.IUnionEncoder <TEvent, byte[]> Create <TEvent>( Func <TEvent, Tuple <string, byte[]> > encode, Func <string, byte[], TEvent> tryDecode, JsonSerializerSettings settings = null) where TEvent : class { return(Equinox.UnionCodec.JsonUtf8.Create <TEvent>( FuncConvert.FromFunc(encode), FuncConvert.FromFunc((Func <Tuple <string, byte[]>, FSharpOption <TEvent> >)TryDecodeImpl))); FSharpOption <TEvent> TryDecodeImpl(Tuple <string, byte[]> encoded) => OptionModule.OfObj(tryDecode(encoded.Item1, encoded.Item2)); }
public void FSharpFunc() { Equal(I.Module.ReturnsFunc().Invoke(3), 3); Equal(I.Module.ReturnsFunc2().Invoke(1).Invoke(2), 3); Func <int, int> f = I.Module.ReturnsFunc().Invoke; Equal(f(3), 3); Equal(I.Module.InvokeFunc(FSharpConvert.Fun((int x) => x + 1), 1), 2); Equal(I.Module.InvokeFunc2(FSharpConvert.Fun((int x, int y) => x + y), 1, 2), 3); Equal(I.Module.InvokeFunc(FuncConvert.FromFunc((int x) => x + 1), 1), 2); Equal(I.Module.InvokeFunc2(FuncConvert.FromFunc((int x, int y) => x + y), 1, 2), 3); }
/// Run the decision method, letting it decide whether or not the Command's intent should manifest as Events public async Task <Unit> Execute(Func <TState, IEnumerable <TEvent> > interpret) { FSharpList <TEvent> decide_(TState state) { var a = new Accumulator <TEvent, TState>(_fold, state); a.Execute(interpret); return(ListModule.OfSeq(a.Accumulated)); } return(await FSharpAsync.StartAsTask(Transact(FuncConvert.FromFunc <TState, FSharpList <TEvent> >(decide_)), null, null)); }
public static Arbitrary <IConfirmableMessage> CreateConfirmableMessage() { Func <string, long, IConfirmableMessage> combiner = (senderId, confirmationId) => new ConfirmableMessageEnvelope(confirmationId, senderId, string.Empty); return(Arb.From(Gen.Map2(FuncConvert.FromFunc(combiner), Gen.Elements("a", "b", "c", "d", "e", "f", "g"), // restrict the number of possible senders to something small Arb.Default.Int64().Generator.Where(x => x > 0)))); //return Arb.From(Arb.Default.Int64().Generator.Where(x => x > 0) // .Select(x => (IConfirmableMessage)new ConfirmableMessageEnvelope(x, "foo", string.Empty))); }
public IViewBuilder Property <TValue>(string property, TValue value, Func <TView, TValue> getter, Action <TView, TValue> setter, Func <TValue, TValue, bool> comparer) { var cmp = comparer == null ? FSharpValueOption <FSharpFunc <Tuple <object, object>, bool> > .None : FSharpValueOption <FSharpFunc <Tuple <object, object>, bool> > .Some(FuncConvert.FromFunc <Tuple <object, object>, bool>(t => comparer((TValue)t.Item1, (TValue)t.Item2))); var get = getter == null ? FSharpValueOption <FSharpFunc <TView, TValue> > .None : FSharpValueOption <FSharpFunc <TView, TValue> > .Some(FuncConvert.FromFunc(getter)); var set = setter == null ? FSharpValueOption <FSharpFunc <Tuple <TView, TValue>, Unit> > .None : FSharpValueOption <FSharpFunc <Tuple <TView, TValue>, Unit> > .Some(FuncConvert.FromAction <Tuple <TView, TValue> >(tup => setter(tup.Item1, tup.Item2))); Attrs.Add(Avalonia.FuncUI.Builder.AttrBuilder <TView> .CreateProperty(property, value, get, set, cmp)); return(this); }
public Move FindBestMove(Game game) { FSharpFunc <Game, bool> gameOver = FuncConvert.FromFunc <Game, bool>(GameOver); FSharpFunc <Game, FSharpFunc <Player, int> > heuristic = FuncConvert.FromFunc <Game, Player, int>(Heuristic); FSharpFunc <Game, Player> getTurn = FuncConvert.FromFunc <Game, Player>(GetTurn); FSharpFunc <Game, IEnumerable <Move> > moveGenerator = FuncConvert.FromFunc <Game, IEnumerable <Move> >(MoveGenerator); FSharpFunc <Game, FSharpFunc <Move, Game> > applyMove = FuncConvert.FromFunc <Game, Move, Game>(ApplyMove); OptimizedClosures.FSharpFunc <int, int, Game, Player, Tuple <FSharpOption <Move>, int> > mini = (OptimizedClosures.FSharpFunc <int, int, Game, Player, Tuple <FSharpOption <Move>, int> >)GameTheory.MiniMaxWithAlphaBetaPruningGenerator(heuristic, getTurn, gameOver, moveGenerator, applyMove); NodeCounter.Reset(); Tuple <FSharpOption <Move>, int> best = mini.Invoke(int.MinValue, int.MaxValue, game, game.Turn); Move move = best.Item1.Value; return(move); }
public override Func <Target, Equinox.Core.IStream <TEvent, TState> > Resolve <TEvent, TState>( FsCodec.IUnionEncoder <TEvent, byte[], object> codec, Func <TState, IEnumerable <TEvent>, TState> fold, TState initial, Func <TEvent, bool> isOrigin = null, Func <TState, TEvent> compact = null) { var accessStrategy = isOrigin == null && compact == null ? null : AccessStrategy <TEvent, TState> .NewSnapshot(FuncConvert.FromFunc(isOrigin), FuncConvert.FromFunc(compact)); var cacheStrategy = _cache == null ? null : CachingStrategy.NewSlidingWindow(_cache, TimeSpan.FromMinutes(20)); var resolver = new Resolver <TEvent, TState, object>(_store, codec, FuncConvert.FromFunc(fold), initial, cacheStrategy, accessStrategy); return(t => resolver.Resolve(t)); }
public void FSharpFunc() { Equal(I.Module.ReturnsFunc().Invoke(3), 3); Equal(I.Module.ReturnsFunc2().Invoke(1).Invoke(2), 3); Func <int, int> f = I.Module.ReturnsFunc().Invoke; Equal(f(3), 3); Equal(I.Module.InvokeFunc(FSharpConvert.Fun((int x) => x + 1), 1), 2); Equal(I.Module.InvokeFunc2(FSharpConvert.Fun((int x, int y) => x + y), 1, 2), 3); Equal(I.Module.InvokeFunc(FuncConvert.FromFunc((int x) => x + 1), 1), 2); Equal(I.Module.InvokeFunc2(FuncConvert.FromFunc((int x, int y) => x + y), 1, 2), 3); Equal(I.Module.InvokeFunc(FuncConvert.ToFSharpFunc((int x) => x + 1), 1), 2); var c = FSharpFunc <int, int> .ToConverter(I.Module.ReturnsFunc()); Equal(c(3), 3); var f2 = FSharpFunc <int, int> .FromConverter(c); Equal(f2.Invoke(3), 3); }
public override Func <string, IStream <TEvent, TState> > Resolve <TEvent, TState>( FsCodec.IEventCodec <TEvent, byte[], object> codec, Func <TState, IEnumerable <TEvent>, TState> fold, TState initial, Func <TEvent, bool> isOrigin = null, Func <TState, TEvent> toSnapshot = null) { var accessStrategy = isOrigin == null && toSnapshot == null ? null : AccessStrategy <TEvent, TState> .NewRollingSnapshots(FuncConvert.FromFunc(isOrigin), FuncConvert.FromFunc(toSnapshot)); var cacheStrategy = _cache == null ? null : CachingStrategy.NewSlidingWindow(_cache, TimeSpan.FromMinutes(20)); var cat = new EventStoreCategory <TEvent, TState, object>(_connection, codec, FuncConvert.FromFunc(fold), initial, cacheStrategy, accessStrategy); return(t => cat.Resolve(t)); }
public override Func <Target, IStream <TEvent, TState> > Resolve <TEvent, TState>( IUnionEncoder <TEvent, byte[]> codec, Func <TState, IEnumerable <TEvent>, TState> fold, TState initial, Func <TEvent, bool> isOrigin = null, Func <TState, TEvent> compact = null) { var accessStrategy = isOrigin == null && compact == null ? null : AccessStrategy <TEvent, TState> .NewRollingSnapshots(FuncConvert.FromFunc(isOrigin), FuncConvert.FromFunc(compact)); var cacheStrategy = _cache == null ? null : CachingStrategy.NewSlidingWindow(_cache, TimeSpan.FromMinutes(20)); var resolver = new GesResolver <TEvent, TState>(_gateway, codec, FuncConvert.FromFunc(fold), initial, accessStrategy, cacheStrategy); return(t => resolver.Resolve.Invoke(t)); }
/// <summary> /// Modify parameters of an FsCheck.Config. /// </summary> public static FsCheckConfig With( this FsCheckConfig config, List <Type> Arbitrary = null, int?EndSize = null, Func <int, object[], string> Every = null, Func <object[], string> EveryShrink = null, int?MaxRejected = null, int?MaxTest = null, string Name = null, ParallelRunConfig ParallelRunConfig = null, bool?QuietOnSuccess = null, Tuple <ulong, ulong, int> Replay = null, IRunner Runner = null, int?StartSize = null) { // Create complex FSharp type var replay = config.Replay; if (Replay != null) { replay = FSharpOption <Replay> .Some( new Replay(new Rnd(Replay.Item1, Replay.Item2), FSharpOption <int> .Some(Replay.Item3)) ); } // Create complex FSharp type var parallelRunConfig = config.ParallelRunConfig; if (ParallelRunConfig != null) { parallelRunConfig = FSharpOption <ParallelRunConfig> .Some( new ParallelRunConfig(ParallelRunConfig.MaxDegreeOfParallelism) ); } // Create complex FSharp func var every = config.Every; if (Every != null) { every = FuncConvert.FromFunc( (Func <int, FSharpList <object>, string>)((numTest, list) => Every(numTest, list.ToArray())) ); } // Create complex FSharp func var everyShrink = config.EveryShrink; if (Every != null) { everyShrink = FuncConvert.FromFunc( (Func <FSharpList <object>, string>)(list => EveryShrink(list.ToArray())) ); } var result = new FsCheckConfig( MaxTest ?? config.MaxTest, MaxRejected ?? config.MaxRejected, replay, Name ?? config.Name, StartSize ?? config.StartSize, EndSize ?? config.EndSize, QuietOnSuccess ?? config.QuietOnSuccess, every, everyShrink, ToFSharpList(Arbitrary) ?? config.Arbitrary, Runner ?? config.Runner, parallelRunConfig ); return(result); FSharpList <T> ToFSharpList <T>(IEnumerable <T> elements) { return(elements?.Reverse() .Aggregate(FSharpList <T> .Empty, (list, head) => FSharpList <T> .Cons(head, list))); } }
// Project from the synchronized state, without the possibility of adding events that Decide(Func) admits public async Task <T> Query <T>(Func <TState, T> project) => await FSharpAsync.StartAsTask(Query(FuncConvert.FromFunc(project)), null, null);
// Execute a command, as Decide(Action) does, but also yield an outcome from the decision public async Task <T> Decide <T>(Func <Context <TEvent, TState>, T> interpret) => await FSharpAsync.StartAsTask <T>(Decide(FuncConvert.FromFunc(interpret)), null, null);
public static void Execute <TEvent, TState>(this Accumulator <TEvent, TState> that, Func <TState, IEnumerable <TEvent> > f) => that.Transact(FuncConvert.FromFunc <TState, FSharpList <TEvent> >(s => ListModule.OfSeq(f(s))));
public static void Execute <TEvent, TState>(this Context <TEvent, TState> that, Func <TState, IEnumerable <TEvent> > f) => that.Execute(FuncConvert.FromFunc <TState, FSharpList <TEvent> >(s => ListModule.OfSeq(f(s))));
static int Main() { // Some typical code { Microsoft.FSharp.Core.FSharpOption <int> x = Microsoft.FSharp.Core.FSharpOption <int> .Some(3); System.Console.WriteLine("{0}", x.Value); Microsoft.FSharp.Collections.FSharpList <int> x2 = Microsoft.FSharp.Collections.FSharpList <int> .Cons(3, Microsoft.FSharp.Collections.FSharpList <int> .Empty); System.Console.WriteLine("{0}", x2.Head); } { FSharpList <int> x = FSharpList <int> .Cons(3, (FSharpList <int> .Empty)); Console.WriteLine("x - IsCons = {0}", x != null); Console.WriteLine("x - IsNil = {0}", x == null); Console.WriteLine("x.Head = {0}", x.Head); Console.WriteLine("x.Tail = {0}", x.Tail); Console.WriteLine("x.Tail - IsNil = {0}", x.Tail); switch (x.Tag) { case FSharpList <int> .Tags.Cons: Console.WriteLine("Cons({0},{1})", x.Head, x.Tail); break; case FSharpList <int> .Tags.Empty: Console.WriteLine("[]"); break; } } { FSharpList <int> x = FSharpList <int> .Cons(3, (FSharpList <int> .Empty)); foreach (int i in x) { Console.WriteLine("i = {0}", i); } } { FSharpList <int> myList = ListModule.OfArray(new int[] { 4, 5, 6 }); ListModule.Iterate (FuncConvert.ToFSharpFunc((Action <int>) delegate(int i) { Console.WriteLine("i = {0}", i); }), myList); // tests op_Implicit ListModule.Iterate <int> ((Converter <int, Unit>) delegate(int i) { Console.WriteLine("i = {0} (2nd technique)", i); return(null); }, myList); // tests op_Implicit FSharpList <string> myList2 = ListModule.Map (FuncConvert.ToFSharpFunc((Converter <int, string>) delegate(int i) { return(i.ToString() + i.ToString()); }), myList); // tests op_Implicit ListModule.Iterate (FuncConvert.ToFSharpFunc((Action <string>) delegate(string s) { Console.WriteLine("i after duplication = {0}", s); }), myList2); // tests op_Implicit myList2 = ListModule.Map <int, string> ((Converter <int, string>) delegate(int i) { return(i.ToString() + i.ToString()); }, myList); ListModule.Iterate <string> (FuncConvert.ToFSharpFunc((Action <string>) delegate(string s) { Console.WriteLine("i after duplication (2nd technique) = {0}", s); }), myList2); myList2 = ListModule.Map <int, string> (FuncConvert.ToFSharpFunc(delegate(int i) { return(i.ToString() + i.ToString()); }), myList); myList2 = ListModule.Map <int, string> (FuncConvert.FromFunc((Func <int, string>) delegate(int i) { return(i.ToString() + i.ToString()); }), myList); ListModule.Iterate <string>(FuncConvert.ToFSharpFunc <string>(s => { Console.WriteLine("s = {0}", s); }), myList2); ListModule.Iterate <string>(FuncConvert.FromAction <string>(s => { Console.WriteLine("s = {0}", s); }), myList2); ListModule.Iterate <string>(FuncConvert.FromFunc <string, Microsoft.FSharp.Core.Unit>(s => null), myList2); myList2 = ListModule.Map <int, string>(FuncConvert.ToFSharpFunc <int, string>(i => i.ToString() + i.ToString()), myList); myList2 = ListModule.Map <int, string>(FuncConvert.FromFunc <int, string>(i => i.ToString() + i.ToString()), myList); myList2 = ListModule.MapIndexed <int, string>(FuncConvert.FromFunc <int, int, string>((i, j) => i.ToString() + j), myList); var trans3 = FuncConvert.FromFunc <int, int, int, int>((i, j, k) => i + j + k); var trans4 = FuncConvert.FromFunc <int, int, int, int, int>((i, j, k, l) => i + j + k + l); var trans5 = FuncConvert.FromFunc <int, int, int, int, int, int>((i, j, k, l, m) => i + j + k + l + m); var action3 = FuncConvert.FromAction <int, int, int>((i, j, k) => System.Console.WriteLine("action! {0}", i + j + k)); var action4 = FuncConvert.FromAction <int, int, int, int>((i, j, k, l) => System.Console.WriteLine("action! {0}", i + j + k + l)); var action5 = FuncConvert.FromAction <int, int, int, int, int>((i, j, k, l, m) => System.Console.WriteLine("action! {0}", i + j + k + l + m)); ListModule.Iterate <string>(FuncConvert.ToFSharpFunc <string>(s => { Console.WriteLine("i after duplication (2nd technique) = {0}", s); }), myList2); ListModule.Iterate <string>(FuncConvert.FromAction <string>(s => { Console.WriteLine("i after duplication (2nd technique) = {0}", s); }), myList2); } // Construct a value of each type from the library Lib.Recd1 r1 = new Lib.Recd1(3); Lib.Recd2 r2 = new Lib.Recd2(3, "a"); Lib.RevRecd2 rr2 = new Lib.RevRecd2("a", 3); Lib.Recd3 <string> r3 = new Lib.Recd3 <string>(4, "c", null); r3.recd3field3 = r3; Lib.One d10a = Lib.One.One; Lib.Int d11a = Lib.Int.NewInt(3); Lib.IntPair ip = Lib.IntPair.NewIntPair(3, 4); Console.WriteLine("{0}", ip.Item1); Console.WriteLine("{0}", ip.Item2); Lib.IntPear ip2 = Lib.IntPear.NewIntPear(3, 4); Console.WriteLine("{0}", ip2.Fst); Console.WriteLine("{0}", ip2.Snd); Lib.Bool b = Lib.Bool.True; Console.WriteLine("{0}", Lib.Bool.True); Console.WriteLine("{0}", Lib.Bool.False); //Console.WriteLine("{0}", Lib.Bool.IsTrue(b)); //Console.WriteLine("{0}", Lib.Bool.IsFalse(b)); switch (b.Tag) { case Lib.Bool.Tags.True: Console.WriteLine("True"); break; case Lib.Bool.Tags.False: Console.WriteLine("False"); break; } Lib.OptionalInt oint = Lib.OptionalInt.NewSOME(3); Console.WriteLine("oint - IsSOME = {0}", oint != null); Console.WriteLine("oint - IsNONE = {0}", oint == null); Console.WriteLine("{0}", (oint as Lib.OptionalInt.SOME).Item); switch (oint.Tag) { case Lib.OptionalInt.Tags.SOME: var c = oint as Lib.OptionalInt.SOME; Console.WriteLine("SOME({0})", c.Item); break; case Lib.OptionalInt.Tags.NONE: Console.WriteLine("NONE"); break; } Lib.IntOption iopt = Lib.IntOption.Nothing; Console.WriteLine("iopt - IsSomething = {0}", iopt != null); Console.WriteLine("iopt - IsNothing = {0}", iopt == null); switch (iopt.Tag) { case Lib.IntOption.Tags.Something: Console.WriteLine("Something({0})", (iopt as Lib.IntOption.Something).Item); break; case Lib.IntOption.Tags.Nothing: Console.WriteLine("Nothing"); break; } Lib.GenericUnion <int, string> gu1 = Lib.GenericUnion <int, string> .Nothing; Lib.GenericUnion <int, string> gu2 = Lib.GenericUnion <int, string> .NewSomething(3, "4"); Lib.GenericUnion <int, string> gu3 = Lib.GenericUnion <int, string> .NewSomethingElse(3); Lib.GenericUnion <int, string> gu4 = Lib.GenericUnion <int, string> .NewSomethingElseAgain(4); //Console.WriteLine("{0}", (gu1 as Lib.GenericUnion<int,string>.Cases.Nothing)); Console.WriteLine("{0}", (gu2 as Lib.GenericUnion <int, string> .Something).Item1); Console.WriteLine("{0}", (gu3 as Lib.GenericUnion <int, string> .SomethingElse).Item); Console.WriteLine("{0}", (gu4 as Lib.GenericUnion <int, string> .SomethingElseAgain).Item); switch (gu1.Tag) { case Lib.GenericUnion <int, string> .Tags.Nothing: Console.WriteLine("OK"); break; case Lib.GenericUnion <int, string> .Tags.Something: case Lib.GenericUnion <int, string> .Tags.SomethingElse: case Lib.GenericUnion <int, string> .Tags.SomethingElseAgain: Console.WriteLine("NOT OK"); throw (new System.Exception("ERROR - INCORRECT CASE TAG")); } switch (gu2.Tag) { case Lib.GenericUnion <int, string> .Tags.Something: Console.WriteLine("OK"); break; case Lib.GenericUnion <int, string> .Tags.Nothing: case Lib.GenericUnion <int, string> .Tags.SomethingElse: case Lib.GenericUnion <int, string> .Tags.SomethingElseAgain: Console.WriteLine("NOT OK"); throw (new System.Exception("ERROR - INCORRECT CASE TAG")); } Lib.BigUnion bu1 = Lib.BigUnion.NewA1(3); Lib.BigUnion bu2 = Lib.BigUnion.NewA2(3); Lib.BigUnion bu3 = Lib.BigUnion.NewA3(3); Lib.BigUnion bu4 = Lib.BigUnion.NewA4(3); Lib.BigUnion bu5 = Lib.BigUnion.NewA5(3); Lib.BigUnion bu6 = Lib.BigUnion.NewA6(3); Lib.BigUnion bu7 = Lib.BigUnion.NewA7(3); Lib.BigUnion bu8 = Lib.BigUnion.NewA8(3); Lib.BigUnion bu9 = Lib.BigUnion.NewA9(3); switch (bu1.Tag) { case Lib.BigUnion.Tags.A1: Console.WriteLine("OK"); break; case Lib.BigUnion.Tags.A2: case Lib.BigUnion.Tags.A3: case Lib.BigUnion.Tags.A4: case Lib.BigUnion.Tags.A5: case Lib.BigUnion.Tags.A6: case Lib.BigUnion.Tags.A7: case Lib.BigUnion.Tags.A8: case Lib.BigUnion.Tags.A9: Console.WriteLine("NOT OK"); throw (new System.Exception("ERROR - INCORRECT CASE TAG")); } Lib.BigEnum be1 = Lib.BigEnum.E1; Lib.BigEnum be2 = Lib.BigEnum.E2; Lib.BigEnum be3 = Lib.BigEnum.E3; Lib.BigEnum be4 = Lib.BigEnum.E4; Lib.BigEnum be5 = Lib.BigEnum.E5; Lib.BigEnum be6 = Lib.BigEnum.E6; Lib.BigEnum be7 = Lib.BigEnum.E7; Lib.BigEnum be8 = Lib.BigEnum.E8; Lib.BigEnum be9 = Lib.BigEnum.E9; switch (be1.Tag) { case Lib.BigEnum.Tags.E1: Console.WriteLine("OK"); break; case Lib.BigEnum.Tags.E2: case Lib.BigEnum.Tags.E3: case Lib.BigEnum.Tags.E4: case Lib.BigEnum.Tags.E5: case Lib.BigEnum.Tags.E6: case Lib.BigEnum.Tags.E7: case Lib.BigEnum.Tags.E8: case Lib.BigEnum.Tags.E9: Console.WriteLine("NOT OK"); throw (new System.Exception("ERROR - INCORRECT CASE TAG")); } Lib.Index d211a = Lib.Index.NewIndex_A(3); Lib.Bool d200b = Lib.Bool.False; Lib.OptionalInt d210b = Lib.OptionalInt.NONE; Lib.IntOption d201b = Lib.IntOption.NewSomething(3); Lib.Index d211b = Lib.Index.NewIndex_B(4); /* * * type discr2_0_0 = True | False * type discr2_0_1 = Nothing | Something of int * type discr2_1_0 = SOME of int | NONE * type discr2_1_1 = Index_A of int | Index_B of int * * type discr3_0_0_0 = Discr3_0_0_0_A | Discr3_0_0_0_B | Discr3_0_0_0_C * type discr3_0_1_0 = Discr3_0_1_0_A | Discr3_0_1_0_B of int | Discr3_0_0_0_C * type discr3_1_0_0 = Discr3_1_0_0_A of int | Discr3_1_0_0_B | Discr3_0_0_0_C * type discr3_1_1_0 = Discr3_1_1_0_A of int | Discr3_1_1_0_B of int | Discr3_0_0_0_C * type discr3_0_0_1 = Discr3_0_0_0_A | Discr3_0_0_0_B | Discr3_0_0_0_C of string * type discr3_0_1_1 = Discr3_0_1_0_A | Discr3_0_1_0_B of int | Discr3_0_0_0_C of string * type discr3_1_0_1 = Discr3_1_0_0_A of int | Discr3_1_0_0_B | Discr3_0_0_0_C of string * type discr3_1_1_1 = Discr3_1_1_0_A of int | Discr3_1_1_0_B of int | Discr3_0_0_0_C of string */ // Toplevel functions * int f_1 = Lib.f_1(1); int f_1_1 = Lib.f_1_1(1, 2); int f_1_1_1 = Lib.f_1_1_1(1, 2, 3); int f_1_1_1_1 = Lib.f_1_1_1_1(1, 2, 3, 4); int f_1_1_1_1_1 = Lib.f_1_1_1_1_1(1, 2, 3, 4, 5); #if DELEGATES int f_1_effect_1 = Lib.f_1_effect_1(1)(2); #else int f_1_effect_1 = Lib.f_1_effect_1(1).Invoke(2); #endif //let f_2 x y = x+y //let f_3 x y z = x+y+z //let f_4 x1 x2 x3 x4 = x1+x2+x3+x4 //let f_5 x1 x2 x3 x4 x5 = x1+x2+x3+x4+x5 // Function returning a function //let f_1_1 x = let x = ref 1 in fun y -> !x+y+1 // Tuple value //let tup2 = (2,3) //let tup3 = (2,3,4) //let tup4 = (2,3,4,5) System.Console.WriteLine("Test Passed."); return(0); }
public IViewBuilder Property <TValue>(AvaloniaProperty property, TValue value, Func <TValue, TValue, bool> comparer) { Attrs.Add(Avalonia.FuncUI.Builder.AttrBuilder <TView> .CreateProperty(property, value, FSharpValueOption <FSharpFunc <Tuple <object, object>, bool> > .Some(FuncConvert.FromFunc <Tuple <object, object>, bool>(t => comparer((TValue)t.Item1, (TValue)t.Item2))))); return(this); }