Can an F# query expression filter for items that are NOT in a sub-query?

I have the following sample that finds the numbers in s1 that are not in s2. let s1 = seq { 1..3 } let s2 = seq { 3..4 } s1 |> Seq.filter (fun x -> s2 |> Seq.forall (fun y -> x <> y)) |> Seq.iter (fun x -> printfn $"{x}") This prints 1… Read More Can an F# query expression filter for items that are NOT in a sub-query?

F# – how can I convert an F# function into a System.Delegate using reflection?

Say I have a basic function, like: let double x = x * 2 Since I know the types, I can convert it into a Func<_,_> explicitly, which can then be used as a Delegate: let doubleFuncExplicit = Func<int, int>(double) However, when I attempt to do this by using Activator.CreateInstance() instead of the constructor, like… Read More F# – how can I convert an F# function into a System.Delegate using reflection?

How to Await F# Async Code Method from C# ( WPF )

I write most of my backend code in F# – but my WPF project is in C# and I am wiring up progress reporting between the process and UI. My F# Code type DownloadProgressModel = { mutable PercentageComplete: int totalOrders: int mutable orderPosition: int } let doMockDownload(progress: IProgress<DownloadProgressModel>) = async { let downloadprogress: DownloadProgressModel =… Read More How to Await F# Async Code Method from C# ( WPF )

How to do tuple augmentation

The following code is from chapter 5 of "F# 4.0 Design Patterns". let a = 1,"car" type System.Tuple<‘T1,’T2> with member t.AsString() = sprintf "[[%A]:[%A]]" t.Item1 t.Item2 (a |> box :?> System.Tuple<int,string>).AsString() The desired output is [[1]:["car"]] However, a red squiggly appears under AsString(). "The field, constructor or member ‘AsString’ is not defined. Maybe you want… Read More How to do tuple augmentation

How to unsubscribe an event from inside the event handler?

My code subscribes to an event and it needs to unsubscribe (Dispose) once the event has been handled. However this looks like a chicken-egg problem. Using rec doesn’t work and I cannot find how to do it. It there any well-konwn pattern to bypass this limitation? let process = new Process() let exitSubscription = process.Exited.Subscribe… Read More How to unsubscribe an event from inside the event handler?