f#

Silverlight HttpWebRequest.Create hangs inside async block

可紊 提交于 2019-12-20 21:46:52
问题 I am trying to prototype a Rpc Call to a JBOSS webserver from Silverlight (4). I have written the code and it is working in a console application - so I know that Jboss is responding to the web request. Porting it to silverlight 4, is causing issues: let uri = new Uri(queryUrl) // this is the line that hangs let request : HttpWebRequest = downcast WebRequest.Create(uri) request.Method <- httpMethod; request.ContentType <- contentType It may be a sandbox issue, as my silverlight is being

How does F# Interactive #I command know about project path?

偶尔善良 提交于 2019-12-20 20:16:10
问题 Here is the scenario: Open Visual Studio. This was done in VS2010 Pro. Open F# Interactive within Visual Studio Open project with fsx file Note: Project and fsx file are in E:\<directories>\fsharp-tapl\arith Send commands to F# Interactive from fsx file > System.Environment.CurrentDirectory;; val it : string = "C:\Users\Eric\AppData\Local\Temp" I was not expecting a Temp directory but it makes sense. > #r @"arith.exe" Examples.fsx(7,1): error FS0082: Could not resolve this reference. Could

Are there any good F# text editors?

落花浮王杯 提交于 2019-12-20 18:29:20
问题 Are there any good text editors for F#? Instead of firing up resource-intensive Visual Studio, I would like to know if there are any text editors that can pretty-format F# code. I am just getting started with F# and learning through FSI.exe with Notepad is giving me so much trouble... 回答1: Check this out: F# Without Visual Studio 回答2: Not to be too much of a tease, but looking ahead, VS2010 uses a new rehostable editor component, you can hear some about it here: Hanselminutes Podcast 147 -

Are there any good F# text editors?

自闭症网瘾萝莉.ら 提交于 2019-12-20 18:28:21
问题 Are there any good text editors for F#? Instead of firing up resource-intensive Visual Studio, I would like to know if there are any text editors that can pretty-format F# code. I am just getting started with F# and learning through FSI.exe with Notepad is giving me so much trouble... 回答1: Check this out: F# Without Visual Studio 回答2: Not to be too much of a tease, but looking ahead, VS2010 uses a new rehostable editor component, you can hear some about it here: Hanselminutes Podcast 147 -

Performance Implications of Point-Free style

十年热恋 提交于 2019-12-20 17:34:26
问题 I’m taking my first baby-steps in learning functional programing using F# and I’ve just come across the Forward Pipe (|>) and Forward Composition (>>) operators. At first I thought they were just sugar rather than having an effect on the final running code (though I know piping helps with type inference). However I came across this SO article: What are advantages and disadvantages of “point free” style in functional programming? Which has two interesting and informative answers (that instead

Documenting F# Code

Deadly 提交于 2019-12-20 16:51:08
问题 In a C# class with a single constructor, I can add class summary XML documentation and constructor XML documentation: ///<summary> ///This class will solve all your problems ///</summary> public class Awesome { /// <summary> /// Initializes a new instance of the <see cref="Awesome"/> class. /// </summary> /// <param name="sauce">The secret sauce.</param> public Awesome(string sauce) { //...implementation elided for security purposes } } How do I do the same with the equivalent F# class such

Does F# have 'newtype' of Haskell?

拥有回忆 提交于 2019-12-20 14:45:11
问题 New Library: XParsec This question has lead to a stream-type-independent parsec implementation in F# 3.0 - inspired by FParsec, freed from CharStreams and simplified: http://corsis.github.com/XParsec/ In an FParsec-inspired stream-type-independent simple parsec implementation, I wonder how I could distinguish the following at the type level: parsers that consume a piece of stream parsers that work on the current position without moving ahead in the stream Specifically, how can I restrict in F

Read from Console in F#

只愿长相守 提交于 2019-12-20 11:59:08
问题 Does anyone know if there is a builtin function for reading from the console likewise to the printfn function? The only method I've seen so far is using System.Console.Read() but it doesn't feel as functional as using a construct like printfn is. 回答1: It is indeed a shame that there is no such built-in function. However, as Brian mentioned in a comment on Benjol's answer, it is possible to build a scanf function yourself. Here's a quick sketch of how one might define a sscanf variant,

why does F# inline cause 11x performance improvement

孤街醉人 提交于 2019-12-20 09:55:11
问题 I am working on some heavy cpu bound problem. I see a big performance improvement when I use the inline keyword. I create a dictionary from the standard .net library passing in a custom key Comparer see code and timing results below https://gist.github.com/4409734 without inline keyword on Eq_cmp > perf_run 10000000 ;; Real: 00:00:11.039, CPU: 00:00:11.029, GC gen0: 771, gen1: 3, gen2: 1 val it : unit = () using inline keyword on Eq_cmp perf_run 10000000 ;; Real: 00:00:01.319, CPU: 00:00:01

Call a higher order F# function from C#

偶尔善良 提交于 2019-12-20 09:37:37
问题 Given the F# higher order function (taking a function in parameter): let ApplyOn2 (f:int->int) = f(2) and the C# function public static int Increment(int a) { return a++; } How do I call ApplyOn2 with Increment as parameter (from C#)? Note that ApplyOn2 is exported as Microsoft.FSharp.Core.FSharpFunc<int,int> which do not match with Increment 's signature. 回答1: If you would like to provide a more friendly interop experience, consider using the System.Func delegate type directly in F#: let