f#

Install F# 4.1 SDK on build server

旧巷老猫 提交于 2021-01-27 05:49:43
问题 I have installed Visual Studio 2017 with F# support on my PC and I have MSBuild targets in C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\FSharp and F# 4.1 SDK in C:\Program Files (x86)\Microsoft SDKs\F#\4.1 I have installed Build Tools for Visual Studio 2017 (from https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15 ) but there is no option to install F# SDK so building F# projects using MSBuild 15 fails.

Performance of List.permute

僤鯓⒐⒋嵵緔 提交于 2021-01-27 05:28:15
问题 I implemented a Fisher-Yates shuffle recently, which used List.permute to shuffle the list, and noted that as the size of the list increased, there was a significant performance decrease. I suspect this is due to the fact that while the algorithm assumes it is operating on an array, permute must be accessing the list elements by index, which is O(n). To confirm this, I tried out applying a permutation to a list to reverse its element, comparing working directly on the list, and transforming

Performance of List.permute

可紊 提交于 2021-01-27 05:27:07
问题 I implemented a Fisher-Yates shuffle recently, which used List.permute to shuffle the list, and noted that as the size of the list increased, there was a significant performance decrease. I suspect this is due to the fact that while the algorithm assumes it is operating on an array, permute must be accessing the list elements by index, which is O(n). To confirm this, I tried out applying a permutation to a list to reverse its element, comparing working directly on the list, and transforming

F# groupBy - System.Exception : unrecognized method call

吃可爱长大的小学妹 提交于 2021-01-27 04:41:13
问题 I'm trying to query data with F# SqlDataProvider but I got strange error when I'd like to use groupBy function my init code : r# "packages/FSharp.Data.2.2.5/lib/net40/FSharp.Data.dll" r# "packages/SQLProvider.1.0.0/lib/FSharp.Data.SQLProvider.dll" r# "packages/FSharp.Data.TypeProviders.5.0.0.2/lib/net40/FSharp.Data.TypeProviders.dll" open FSharp.Data open FSharp.Data.Sql open FSharp.Data.TypeProviders open FSharp.Linq open System.Text.RegularExpressions open System open System.Data type

Adding constant fields to F# discriminated unions

家住魔仙堡 提交于 2021-01-26 10:32:27
问题 Is it possible to add constant field values to F# discriminated unions? Can I do something like this? type Suit | Clubs("C") | Diamonds("D") | Hearts("H") | Spades("S") with override this.ToString() = // print out the letter associated with the specific item end If I were writing a Java enum, I would add a private value to the constructor like so: public enum Suit { CLUBS("C"), DIAMONDS("D"), HEARTS("H"), SPADES("S"); private final String symbol; Suit(final String symbol) { this.symbol =

cancellation token in F# threads

只谈情不闲聊 提交于 2021-01-24 10:46:06
问题 I am struggling with the following: I have a system that has its main flow and has two background threads that can be started and stopped, but they're generally very long running as they stop only during configuration changes. I found that the cancellation token in F# gets checked at async points in the code. The worker threads do not perform any async operations; they are doing background work but nothing is asynchronous. A simplified version looks like that: let workerThread (someParameters

F# How to catch all exceptions

核能气质少年 提交于 2021-01-23 06:25:31
问题 I know how to catch specific exceptions as in the following example: let test_zip_archive candidate_zip_archive = let rc = try ZipFile.Open(candidate_zip_archive.ToString(), ZipArchiveMode.Read) |> ignore zip_file_ok with | :? System.IO.InvalidDataException -> not_a_zip_file | :? System.IO.FileNotFoundException -> file_not_found | :? System.NotSupportedException -> unsupported_exception rc I am reading a bunch of articles to see if I can use a generic exception in the with , like a wildcard

Matching More than One ParserResult and Extracting Values

两盒软妹~` 提交于 2021-01-05 07:09:35
问题 This is a question about working with FParsec's ParserResult. Is there a cleaner implementation of match_result to pull out the XKEYVALUE or XATTRIBUTES contained inside the ParserResult without two nested matches? The following code works as a F# console app... // Learn more about F# at http://fsharp.org open System open FParsec // Types type XKEYVALUE = string * string type XATTRIBUTES = Map< string, string> type PARSER_RESULT_XML = | PR_XKEYVALUE of ParserResult<XKEYVALUE, unit> | PR

Matching More than One ParserResult and Extracting Values

岁酱吖の 提交于 2021-01-05 07:08:53
问题 This is a question about working with FParsec's ParserResult. Is there a cleaner implementation of match_result to pull out the XKEYVALUE or XATTRIBUTES contained inside the ParserResult without two nested matches? The following code works as a F# console app... // Learn more about F# at http://fsharp.org open System open FParsec // Types type XKEYVALUE = string * string type XATTRIBUTES = Map< string, string> type PARSER_RESULT_XML = | PR_XKEYVALUE of ParserResult<XKEYVALUE, unit> | PR

F#.Data HTML Parser Extracting Strings From Nodes

我的梦境 提交于 2021-01-01 04:43:15
问题 I am trying to use FSharp.Data's HTML Parser to extract a string List of links from href attributes. I can get the links printed out to console, however, i'm struggling to get them into a list. Working snippet of a code which prints the wanted links: let results = HtmlDocument.Load(myUrl) let links = results.Descendants("td") |> Seq.filter (fun x -> x.HasClass("pagenav")) |> Seq.map (fun x -> x.Elements("a")) |> Seq.iter (fun x -> x |> Seq.iter (fun y -> y.AttributeValue("href") |> printf "%A