f#

FS2024 Static linking error when PCL project use by TypeProvider

一个人想着一个人 提交于 2020-01-14 11:45:26
问题 It's trying to make a TypeProvider for Xamarin.Forms, but has been plagued by FS2024 error. Parse own library from the XAML of Xamarin.Forms Assign x:Name to Propertis `F# type MainPage = Moonmile.XamarinFormsTypeProvider.XAML<"MainPage.xaml"> // made btn1 and text1 propertis type MainPageEx(target:MainPage) = let mutable count = 0 do // When set event to btn.Clicked, happen FS2024 error. // If this event is comment out, it success build. target.btn1.Clicked.Add( fun e -> count <- count + 1

FS2024 Static linking error when PCL project use by TypeProvider

独自空忆成欢 提交于 2020-01-14 11:44:59
问题 It's trying to make a TypeProvider for Xamarin.Forms, but has been plagued by FS2024 error. Parse own library from the XAML of Xamarin.Forms Assign x:Name to Propertis `F# type MainPage = Moonmile.XamarinFormsTypeProvider.XAML<"MainPage.xaml"> // made btn1 and text1 propertis type MainPageEx(target:MainPage) = let mutable count = 0 do // When set event to btn.Clicked, happen FS2024 error. // If this event is comment out, it success build. target.btn1.Clicked.Add( fun e -> count <- count + 1

FS2024 Static linking error when PCL project use by TypeProvider

送分小仙女□ 提交于 2020-01-14 11:44:12
问题 It's trying to make a TypeProvider for Xamarin.Forms, but has been plagued by FS2024 error. Parse own library from the XAML of Xamarin.Forms Assign x:Name to Propertis `F# type MainPage = Moonmile.XamarinFormsTypeProvider.XAML<"MainPage.xaml"> // made btn1 and text1 propertis type MainPageEx(target:MainPage) = let mutable count = 0 do // When set event to btn.Clicked, happen FS2024 error. // If this event is comment out, it success build. target.btn1.Clicked.Add( fun e -> count <- count + 1

F# TypeProvider “XMLProvider” gives System.Exception

六眼飞鱼酱① 提交于 2020-01-14 10:35:09
问题 I'm trying to process Twitter tweets using the XML type provider as represented by the code below. The code works fine when accessing tweet data values using LINQ XElement functions, however it fails with an exception saying: “XML mismatch: Expected exactly one 'title' child”, when using the type created by the XMLProvider. I know namespaces are not given, however, I don't know how they would be specified with the provider, if they're needed. // ... open FSharp.Net open FSharp.Data let ns =

F# - Parse dates

南楼画角 提交于 2020-01-14 10:08:18
问题 Very basic question regarding parsing date in F#. I am very new to F# and .NET, so please bear with me. My date has the format yyyyMMDD like 20100503 . How do I parse this into a DateTime type in F#. I tried System.DateTime.Parse("20100503"); but get an error. How do I pass a format string into the Parse method?? ANSWER is - Thanks everyone for the responses. let d = System.DateTime.ParseExact("20100503", "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture); 回答1: You should be able

How to call F# type extensions (static member functions) from C#

拈花ヽ惹草 提交于 2020-01-14 10:07:05
问题 FSharp code is structured as following (I'm not in control of the source). namespace FS [<AbstractClass; Sealed>] type TestType() = static member IrrelevantFunction() = 0 [<AutoOpen>] module Extensions = type TestType with //How do we call this from C# static member NeedToCallThis() = 0 module Caller = let CallIt() = //F# can call it TestType.NeedToCallThis() C# calling code is as follows public void Caller() { TestType.IrrelevantFunction(); //We want to call this //TestType.NeedToCallThis();

How to call F# type extensions (static member functions) from C#

笑着哭i 提交于 2020-01-14 10:06:21
问题 FSharp code is structured as following (I'm not in control of the source). namespace FS [<AbstractClass; Sealed>] type TestType() = static member IrrelevantFunction() = 0 [<AutoOpen>] module Extensions = type TestType with //How do we call this from C# static member NeedToCallThis() = 0 module Caller = let CallIt() = //F# can call it TestType.NeedToCallThis() C# calling code is as follows public void Caller() { TestType.IrrelevantFunction(); //We want to call this //TestType.NeedToCallThis();

F#: Add and remove event handlers

天大地大妈咪最大 提交于 2020-01-14 09:48:24
问题 I'm trying to add & remove an event handler from a Silverlight FrameworkElement, but I just can't get the syntax correct. I want to do something like this: let clickedEventHandler = fun args -> printfn "Click!" fe.MouseLeftButtonDown.AddHandler( clickedEventHandler) ... fe.MouseLeftButtonDown.RemoveHandler(clickedEventHandler) What should be the correct way to do this? 回答1: As you already mentioned, you need to create an instance of delegate: let ch = new MouseButtonEventHandler(fun obj args

Exception handling in pipeline sequence

≯℡__Kan透↙ 提交于 2020-01-14 09:10:11
问题 I' working on a basic 2D CAD engine and the pipeline operator significantly improved my code. Basically several functions start with a point (x,y) in space and compute a final position after a number of move operations: let finalPosition = startingPosition |> moveByLengthAndAngle x1 a1 |> moveByXandY x2 y2 |> moveByXandAngle x3 a3 |> moveByLengthAndAngle x4 a4 // etc... This is incredibly easy to read and I'd like to keep it that way. The various x1, a1, etc. obviously have a meaning name in

Windows UI (UWP or 8.1) in F# interactive

梦想的初衷 提交于 2020-01-14 09:06:08
问题 By referencing the default WPF DLLs, it's pretty easy to do anything you could do using code-only WPF: #r "PresentationCore.dll" #r "PresentationFramework.dll" // ...other DLLs... #r "WindowsBase.dll" let window = System.Windows.Window() let panel = System.Windows.Controls.StackPanel() let button = System.Windows.Controls.Button() panel.Children.Add button button.Content <- "hi" window.Content <- panel window.Show() ... and you can manipulate it while the window is still open... button.Click