f#

C# raise An exception of type 'System.MissingMethodException' from a F# library

那年仲夏 提交于 2019-12-24 17:04:14
问题 I made c# project using GeckoFx and I'm calling a f# function in a dll I made. The c# code which calls the function is: var myList = geckoWebBrowser1.ActiveNetworkChannelUrls; hist.Add(geckoWebBrowser1.Url.ToString()); resCoo = geckoWebBrowser1.Document.Cookie; myHTML = geckoWebBrowser1.Document.Body.OuterHtml; // gets the ISIN list from html table var myISINSt = HTMLFuncs.GetISINStocks(myHTML); and the exception is rised on the last row, and is: An exception of type 'System

How to declare global level overload-able operators?

元气小坏坏 提交于 2019-12-24 16:23:29
问题 based on: Is possible to define same-named operator for different argument count? I want to define some operator like + but let call -|- for example to have let a = -|- 1 let b = 1 -|- 1 let c = 1 -|- 1 1 1 1 At least 2 first lines will work for + but how can I declare own operator like this? 回答1: I don't think there is a straightforward way to do this in general. You could probably use an inline operator with a mix of static member constraints to cover some of the cases that you want, but I

F#+.Net, calculation error using the System.Math.Floor function

烂漫一生 提交于 2019-12-24 16:20:54
问题 here's a function I wrote to print every digit of a float number in F#: let rec TestFloor (fnum:float) = let floor = System.Math.Floor(fnum) printfn "fnum:%f floor:%f" fnum floor if floor > 0.0 then TestFloor((fnum - floor) * 10.0) Anyway the result is strange, for example: > TestFloor 1.23;; fnum:1.230000 floor:1.000000 fnum:2.300000 floor:2.000000 **fnum:3.000000 floor:2.000000** fnum:10.000000 floor:9.000000 fnum:10.000000 floor:9.000000 fnum:10.000000 floor:9.000000 fnum:10.000000 floor:9

adding WindowsFormsHost control to MainWindow causes to crash the exe

安稳与你 提交于 2019-12-24 15:28:42
问题 I'm using WPF in F# via FsXaml. The MainWindow works, until I add a WindowsFormsHost control, at which point it will crash with the following error when executed: Unhandled Exception: System.Xaml.XamlObjectWriterException: Cannot create unknown type '{http://schemas.microsoft.com/winfx/2006/xaml/presentation}WindowsFormsHost'. at System.Xaml.XamlObjectWriter.WriteStartObject(XamlType xamlType) at System.Xaml.XamlWriter.WriteNode(XamlReader reader) at FsXaml.InjectXaml.from$cont@37(String file

Quartz.NET and F# - SystemTime and KeyMatcher

99封情书 提交于 2019-12-24 14:45:02
问题 I am trying to work with Quartz.NET in F# and have run into a few issues with the fact that, while Quartz.NET is usable in F#, there does not seem to be much documentation on it, and I've had some difficulty with differences between it and what can find in C#. One issue I have currently run into is setting SystemTime such as shown in this question, Quartz.net + testing with SystemTime.UtcNow. I could be wrong, but I thought that the code in F# should be: SystemTime.Now = fun () -> DateTime

value of CustomEquality and CustomComparison

旧巷老猫 提交于 2019-12-24 13:32:03
问题 I understand the value of asserting [<StructuralEquality;StructuralComparison>] This statically forces equality and comparison constraints to be derived structurally, and have a nice side effect to warn if it can not Similarly [<ReferenceEquality>] forces the equality constraint to be satisfied using reference. Last NoComparison, NoEquality statically unsatisfy those constraints, with the benefit of catching errors as well. However I am unsure what the added value of CustomEquality,

FSharp Functional Composition

故事扮演 提交于 2019-12-24 11:51:25
问题 I have three functions like this: let functionA (i:int) = "functionA" + string i let functionB (i:int) = "functionB" + string i let functionC (i:int) = "functionC" + string i I want to chain these functions together such that the result of executing all three is an array of each of the return values, kind of like Seq.Collect arrayOfFunctions Is there a way to do this declaratively? If I change functionB's parameter from an int to a float, does the answer change? Thanks 回答1: let farr = [|

Are these two Observable Operations Equivalent?

痞子三分冷 提交于 2019-12-24 11:36:59
问题 I'm not sure why, but for some reason when using the observable that is created via concat I will always get all values that are pushed from my list (works as intended). Where as with the normal subscribe it seems that some values never make it to those who have subscribed to the observable (only in certain conditions). These are the two cases that I am using. Could anyone attempt to explain why in certain cases when subscribing to the second version not all values are received? Are they not

F# divide lists

╄→尐↘猪︶ㄣ 提交于 2019-12-24 11:22:43
问题 i'm learning a new programming language, which is F# and I'm struggling to solve a method. I need to divide a list of movies and books into to 2 lists. One where the movies are and another one where the books are listed in. I can't use functions that already exists in F#. I link some exemples what i have done until now. Thank you in advance type Movie = { movieName: string duration: Nat fileSize: Nat } type Book = { bookName: string pages: Nat } type Activity = | Watch of Movie | Read of Book

Cost of RunSynchronously

ⅰ亾dé卋堺 提交于 2019-12-24 10:44:38
问题 What are the reasons why the two timings below differs so dramatically ? let time acquire = let sw = System.Diagnostics.Stopwatch.StartNew() sw.Start() let tsks = [1 .. 10] |> Seq.map (fun x -> acquire) let sec = Async.RunSynchronously(Async.Parallel tsks) sw.Stop() printfn "Generation time %A ms" sw.Elapsed.TotalMilliseconds sw.Reset() Console.ReadKey() |> ignore let custPool = ObjectPool(customerGenerator, 0) let acquire = async { printfn "acquiring cust" ; return! custPool.Get() } let