f#

F# Interactive autocomplete

蹲街弑〆低调 提交于 2019-12-10 12:45:01
问题 Is there any option of getting auto-completion in F# interactive in VS2010? 回答1: There is a visual studio extension here: https://github.com/vlasenkoalexey/FSharp.Interactive.Intellisense It doesn't work as good as the c# interactive intellisense but it can be a good start. 回答2: No. The best way to write code interactively in F# is to create a new script file and write all code in the script file (where you get all the autocompletion and background type checking). Then you just select code

F# Type Providers and Continuous Integration

穿精又带淫゛_ 提交于 2019-12-10 12:43:23
问题 The type definition of an F# type provider often requires a constant expression, e.g. for the SQL type provider: type dbSchema = SqlDataConnection<"Data Source=MySqlServer;Initial Catalog=MyDatabase;"> However, when committing the code to SCM, and further having a build server doing its thing, you probably don’t want to use the same connection string, but rather the connection string of a SQL server database that is generated from the build process. Is there a solution for this problem? It

How to resolve the strange type error in a recursive map with statically resolved type parameters?

六月ゝ 毕业季﹏ 提交于 2019-12-10 12:42:47
问题 type CudaInnerExpr<'t> = CudaInnerExpr of expr: string with member t.Expr = t |> fun (CudaInnerExpr expr) -> expr type CudaScalar<'t> = CudaScalar of name: string with member t.Name = t |> fun (CudaScalar name) -> name type CudaAr1D<'t> = CudaAr1D of CudaScalar<int> * name: string with member t.Name = t |> fun (CudaAr1D (_, name)) -> name type CudaAr2D<'t> = CudaAr2D of CudaScalar<int> * CudaScalar<int> * name: string with member t.Name = t |> fun (CudaAr2D (_, _, name)) -> name type

Why does F# have a unary plus operator?

我的梦境 提交于 2019-12-10 12:35:19
问题 Some languages use a unary plus operator for implicit conversions, such as coercing a string to a number (e.g. Javascript) or casting small number types to an int (e.g. most C-based languages), or to be used when overloading operators. Since the unary plus is primarily used for hackish purposes like this, and also since F# does not perform automatic widening conversions, I was surprised that F# includes the unary plus. What adds to my surprise is that Haskell does not have a unary plus

F# type providers vs C# interfaces + Entity Framework

感情迁移 提交于 2019-12-10 12:35:16
问题 The question is very technical, and it sits deeply between F# / C# differences. It is quite likely that I might’ve missed something. If you find a conceptual error, please, comment and I will update the question. Let’s start from C# world. Suppose that I have a simple business object, call it Person (but, please, keep in mind that there are 100+ objects far more complicated than that in the business domain that we work with): public class Person : IPerson { public int PersonId { get; set; }

What is a good functional language on which to build a web service? [closed]

时间秒杀一切 提交于 2019-12-10 12:33:09
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Is there a functional language that has good support and tools for building web services? I've been looking at Scala (which compiles to the JVM and can use the Java libraries) and F# (which is .NET), but these are young and have some inefficiencies. Scala in particular doesn't support tail-call elimination

CLR vs OCaml exception overhead

最后都变了- 提交于 2019-12-10 12:33:05
问题 Reading Beginning F# - Robert Pickering I focused on the following paragraph: Programmers coming from an OCaml background should be careful when using exceptions in F#. Because of the architecture of the CLR, throwing an exception is pretty expensive—quite a bit more expensive than in OCaml. If you throw a lot of exceptions, profile your code carefully to decide whether the performance costs are worth it. If the costs are too high, revise the code appropriately. Why, because of CLR, throwing

WPF animation slow when the mouse is in the window

馋奶兔 提交于 2019-12-10 12:01:12
问题 I'm trying create a moving rectangle (rect). This is the relevant code: let timer = new Threading.DispatcherTimer(); timer.Tick.Add(fun _ -> Canvas.SetLeft(rect, Canvas.GetLeft(rect)+0.01) |> ignore) timer.Start() The problem is that the animation is slower if I move the mouse over the window. If I set the timer's interval: timer.Interval <- TimeSpan.FromMilliSeconds(30.0) Then the animation doesn't work at all. What am I doing wrong? Thanks. 回答1: I have two suggestions: 1) if you are using f

Asynchronous crawling F#

♀尐吖头ヾ 提交于 2019-12-10 11:37:40
问题 When crawling on webpages I need to be careful as to not make too many requests to the same domain, for example I want to put 1 s between requests. From what I understand it is the time between requests that is important. So to speed things up I want to use async workflows in F#, the idea being make your requests with 1 sec interval but avoid blocking things while waiting for request response. let getHtmlPrimitiveAsyncTimer (uri : System.Uri) (timer:int) = async{ let req = (WebRequest.Create

Solve inheritance dependency in a functional approach

寵の児 提交于 2019-12-10 11:27:04
问题 The problem: Inheritance dependency Type A stores a value of type B in a property Type B inherits from type A We'll consider a UI control hierarchy, where every control belongs to a top-level "Form", and the Form itself is a Control. The author solves this problem by parameterizing classes: [<AbstractClass>] type Control<'Form>(name) = member this.Name = name abstract Form : 'Form type Form(name) = inherit Control<Form>(name) override this.Form = this type Button(name,form) = inherit Control