f#

how to set up windows phone develop environment and using F# to develop application?

假如想象 提交于 2019-12-11 01:25:44
问题 I have already download the windows phone develop tools but I don't know how to using F# to developing the app, currently it's C#. 回答1: Installing a template for 'F# and Windows Phone' into Visual Studio makes life a little easier. If you open Visual Studio and go to Tools->Extension Manager it will open the Extension Manager dialog. From there, if you select the online gallery and type 'F# Windows Phone' into the search box you can find a couple of templates that should help you get started.

F# record with option field doesn't deserialize properly in Asp.Net WebApi 2.x app

落爺英雄遲暮 提交于 2019-12-11 01:19:09
问题 I have a C# Asp.Net MVC (5.2.7) app with support for WebApi 2.x targeting .Net 4.5.1. I am experimenting with F# and I added an F# library project to the solution. The web app references the F# library. Now, I want to be able to have the C# WebApi controller return F# objects and also save F# objects. I have trouble serializing a F# record with an Option field. Here is the code: C# WebApi controller: using System; using System.Collections.Generic; using System.Linq; using System.Net; using

F#: Can someone explain my compiler error?

那年仲夏 提交于 2019-12-11 01:05:38
问题 Anyone know what the problem with this code is? let rec Foo(a,b) = match a () with | None -> Some(b) | Some(c) -> Some(Foo(c,b)) Here's the compiler error: "Type mismatch. Expecting a 'a but given a 'a option The resulting type would be infinite when unifying ''a' and ''a option'" 回答1: Let's try to reproduce how the compiler tries to infer types here. let rec Foo(a,b) = match a () with | None -> Some(b) | Some(c) -> Some(Foo(c,b)) "Ok, so I see a () . a must be a function from unit to some

How to pass a Type as an attribute parameter using F# syntax?

血红的双手。 提交于 2019-12-11 00:54:59
问题 FsCheck allows a custom Arbitrary in its NUnit integration: [<Property(Verbose = true, Arbitrary= [typeof<Test.Arithmetic.MyArb>])>] static member MultiplyIdentity (x: int64) = x * 1 = x This syntax doesn't work. I feel a bit embarrassed to ask, but apparently I never needed this before: how do you specify the type in F# as an attribute parameter? Microsoft says nothing about it, nor does the Wikibooks project and I have some trouble googling this (the word type is omnipresent). Note 1: the

String replace utility conversion from Python to F# [closed]

对着背影说爱祢 提交于 2019-12-11 00:44:10
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . I have a simple python utility code that modifies the string line by line. The code is as follows. import re res = "" with open(

Mapping a list of tuples by tuple members

梦想的初衷 提交于 2019-12-11 00:39:12
问题 Suppose I have a list of decimal*decimal let tup = [(1M, 2M); (2M, 3M); (3M, 3M); (4M, 5M); (5M, 6M); (7M, 6M); (8M, 9M); (10M, 9M)] I need a function that can group all of the values together if they can be connected, e.g., map[(100, [1M; 2M; 3M]); (101, [4M; 5M; 6M; 7M]); (102, [8M; 9M; 10M])] I can't just do a List.groupBy because that misses anything else that may be connected "down the line" by another decimal value. The int values in the map are arbitrary. I'd like to be able to "seed"

F#:Block following this 'let' is unfinished. Expect an expression

丶灬走出姿态 提交于 2019-12-11 00:30:19
问题 I know in F# we should bind every single value to a name. And I think mine is ok??? But in the if statement I have the following error. Block following this 'let' is unfinished. Expect an expression and it comes from let min= List.nth list i . As far as I know I bounded the min to List.nth list i . So why it should be an error? let mutable list =[-1;2;3;4] let mutable min=list.[0] let mutable i=1 if min<=0 then let min= List.nth list i 回答1: If you want to mutate a mutable variable, you can

CsvProvider throws OutOfMemoryException

佐手、 提交于 2019-12-11 00:19:12
问题 FAOCropsLivestock.csv contains more than 14 million row. In my .fs file I have declared type FAO = CsvProvider<"c:\FAOCropsLivestock.csv"> and tried to work with follwoing code FAO.GetSample().Rows.Where(fun x -> x.Country = country) |> .... FAO.GetSample().Filter(fun x -> x.Country = country) |> .... In both cases, exception was thrown. I also have tried with follwoing code after loading the csv file in MSSQL Server type Schema = SqlDataConnection<conStr> let db = Schema.GetDataContext() db

F# NativePtr.stackalloc Unexpected Stack Overflow

你离开我真会死。 提交于 2019-12-11 00:19:11
问题 Still doing my F# performance testing and trying to get stack based arrays working. For some more background see here: f# NativePtr.stackalloc in Struct Constructor. As I understand it, each function call should get its own frame in the stack. This memory is then freed upon return by moving the stack pointer back. However the below causes a stack overflow error - not sure why as the stackalloc is performed inside a function. Interestingly this only happens in Release mode, not Debug mode. I

F# Powerpack's Metadata doesn't recognize FSharp.Core as an F# library

旧街凉风 提交于 2019-12-11 00:09:12
问题 Here's my test code to isolate the problem: open Microsoft.FSharp.Metadata [<EntryPoint>] let main args = let core = FSharpAssembly.FromFile @"C:\Program Files\FSharp-2.0.0.0\\bin\FSharp.Core.dll" let core2 = FSharpAssembly.FSharpLibrary let core3 = System.AppDomain.CurrentDomain.GetAssemblies() |> Seq.find (fun a -> a.FullName.Contains "Core") |> FSharpAssembly.FromAssembly core.Entities |> Seq.iter (printfn "%A") 0 All three let s should give me the same FSharpAssembly. Instead, all 3 throw