f#

Generating specflow stepdefinitions skeleton in f# instead of c#

怎甘沉沦 提交于 2019-12-25 02:26:22
问题 I have been trying to generate f# step definition skeleton file using context menu "Generate Step Definitions" in specflow. But it generates only c#. Is there a way that we tell user preferred language for step definitions. We have most of our acceptance tests written in F# already. Any suggestions are appreciated 回答1: Specflow has some support for F# and it seems that you have a template for generating the definitions when you don't copy them to the clipboard (see Generate step definition

Silverlight IsolatedStorage removed when application is shutdown?

末鹿安然 提交于 2019-12-25 02:15:24
问题 From what I can find, seems like the IsolatedStorage supposed to be permanent unless the user delete it manually. And the following thread says so too: Is Silverlight isolated storage treated as permanent, or as a cache? However seems like if I shut down my application and restart it (as I am debugging on debug mode - not sure if that makes a different), the data I stored earlier is gone. For example, just as pseudocode: onClick = let storage = IsolatedStorageSettings.ApplicationSettings let

Compilation details and reachability algorithms

你离开我真会死。 提交于 2019-12-25 01:25:52
问题 Should I make an analysis of reachability of parts of a graph (called rule): a node can be reached if a certain boolean condition is verified. Each node knows only its predecessor, there are different types of nodes and not all nodes have at guard a condition to be verified. The rule is placed in a file. I made ​the parsing of the rule, I have selected (through the use of discriminated union) and ordered the nodes in accordance with the flow of execution. Now, I should make a kind of static

F# Units of measure, problems with genericity 2

五迷三道 提交于 2019-12-25 01:15:19
问题 Following on from this question, I still seem to be battling at the frontiers of what is possible, though I don't think that I'm doing anything particularly bleeding edge: type Vector2d = { X: float<'u>; Y: float<'u> } Gives me error FS0039: The unit-of-measure parameter 'u' is not defined. And type Vector2d = { X: float<_>; Y: float<_> } Gives me error FS0191: anonymous unit-of-measure variables are not permitted in this declaration. Is it the case that functions can handle 'generic' units

F# fsi.AddPrinter: Does AddPrinter have ability to take list apart?

我们两清 提交于 2019-12-25 00:27:10
问题 In our project we use fsi.AddPrinter for printing type formula<fol>. To make it easier we include fsi.AddPrinter sprint_fol_formula in our fsx files to transform the AST results into human readable results. val inline sprint_fol_formula : formula<fol> -> string In the process of creating test cases we also output both the AST result and the human readable result. The AST result is the result of processing the formulas. To transform the AST into human readable format in the unit test we just

Asynchronous function calls in Parallel

六月ゝ 毕业季﹏ 提交于 2019-12-25 00:25:06
问题 Following version is calling all functions synchronously, I'm looking to find out how to call asynchronous functions in parallel and return all results and errors to the caller. Request let requestAsync (url: string) : Async<Result<string, Error>> = async { Console.WriteLine ("Simulating request " + url) try do! Async.Sleep(1000) return Ok (url + ": body...") with :? WebException as e -> return Error {code = 500; message = "Internal Server Error";} } Test [<TestMethod>] member this

Merge Two Lists in F# Recursively [duplicate]

二次信任 提交于 2019-12-24 23:22:23
问题 This question already has answers here : Merge two lists (5 answers) Closed 3 years ago . I am looking to write a recursive function to merge to integer lists in F# I started with this, but not sure what to do next. let rec merge xs ys = match xs with | [] -> ys | let li = [1;3;5;7;] let ll = [2;4;5;8;] 回答1: As I said in my comment, it's probably easiest if you pattern match on xs and ys simultaneously: let rec merge xs ys = match xs,ys with | [],l | l,[] -> l | x::xs', y::ys' -> if x < y

How to execute this F# function

半世苍凉 提交于 2019-12-24 20:47:28
问题 I tried to execute the following function in multiple ways, but it was always in error. So how do i execute constructQuery : type PersonName = | FirstOnly of string | LastOnly of string | FirstLast of string * string let constructQuery personName = match personName with | FirstOnly(firstName) -> printf "May I call you %s?" firstName | LastOnly(lastName) -> printf "Are you Mr. or Ms. %s?" lastName | FirstLast(firstName, lastName) -> printf "Are you %s %s?" firstName lastName -edit-. I have

Can someone help me compare using F# over C# in this specific example (IP Address expressions)?

本小妞迷上赌 提交于 2019-12-24 19:51:59
问题 So, I am writing code to parse and IP Address expression and turn it into a regular expression that could be run against and IP Address string and return a boolean response. I wrote the code in C# (OO) and it was 110 lines of code. I am trying to compare the amount of code and the expressiveness of C# to F# (I am a C# programmer and a noob at F#). I don't want to post both the C# and F#, just because I don't want to clutter the post. If needed, I will do so. Anyway, I will give an example.

Converting complex Map data structure to F#

牧云@^-^@ 提交于 2019-12-24 18:12:51
问题 I am pretty new to the language F#, let alone functional programming, and I am having trouble implementing a Map data structure. The C# type equivalent of this Map would be: var map = new Dictionary<int, Dictionary<int, Tuple<char, Tuple<int, int>[]>[]>>(); I've tried to implement this myself and searching online, but my inexperience with the language is letting me down. Is anyone able to show me: An immutable implementation of this structure A mutable implementation 回答1: For example like