f#

Deployment of a web application using FSharp.Data to Azure Websites

大城市里の小女人 提交于 2019-12-10 23:42:43
问题 This is a similar question to How do I deploy a web application using F# to Azure Web Site. My C#/F# MVC project uses the FSharp.Data NuGet package, and the deployment process fails with the message Could not locate the assembly "FSharp.Data, Version=1.1.4.0, Culture=neutral, PublicKeyToken=null". The only effective workaround I can see is to replace all of the NuGet references (FSharp.Data, FSharp.Data.DesignTime, FSharp.Data.Experimental, FSharp.Data.Experimental.DesignTime) with explicit

Should ApplicationBase be different for the sandbox AppDomain?

只谈情不闲聊 提交于 2019-12-10 23:38:32
问题 What are the exact security implications of setting ApplicationBase of a slave sandbox domain to the same path as the hosting domain? I found MSDN guidelines that state that ApplicationBase should be different for the slave domain "If the ApplicationBase settings are the same, the partial-trust application can get the hosting application to load (as fully trusted) an exception it defines, thus exploiting it" (p. 3): http://msdn.microsoft.com/en-us/library/bb763046.aspx How exactly would this

How to create an actor in a clustered configuration in F#

筅森魡賤 提交于 2019-12-10 23:35:47
问题 I'm creating a sample with Akka.Cluster with three nodes A, B and C where A is the lighthouse. So far, from the logs, the cluster works fine when there are no actors or when actors are local (created with spawn and spawnOpt ). I want to create an actor from B and access it from C. With let _ = spawne system "r-actor" <@ actorOf (fun msg -> printfn "Received: %s" msg) @> [] I get 2016-08-31 01:59:00.1185|INFO|Akka.Actor.EmptyLocalActorRef|Message String from akka://calculatorSystem/deadLetters

Create new record type inline by extending existing record with new member

我的梦境 提交于 2019-12-10 23:32:45
问题 After asking this question and trying out this suggested solution, I have the following generic entity type: type Entity<'a> = { Id : Guid Data : 'a } Now, before I expose this in an API, I want to flatten it, so that the Id and the properties in Data can be serialized next to each-other. I tried this, but it doesn't compile: let flatten<'a> (v : Entity<'a>) = { v.Data with Id = v.Id } What I had hoped to achieve, was to return a record type such that if 'a is e.g. { foo : string; bar : int }

F# deleting common elements in lists

跟風遠走 提交于 2019-12-10 23:21:41
问题 I'm trying to make a list with only one copy of each element of the original list. For example [1;2;3;3;2] would be [1;2;3] or ["hi";"the";"world";"hi"] would be ["hi";"the";"world"] I'm using recursion and pattern matching, and not using the list modules. Here is my attempt and thinking: I want to go through the list and look at the head, and if that element exists in the tail of the list, then I want to take that element and then remove that element from the existing list let rec common l =

Rotten performance of RSACryptoServiceProvider.VerifyData?

寵の児 提交于 2019-12-10 23:19:44
问题 Is the performance of VerifyData so bad that the function is practically useless, or am I doing something very wrong in the code below? open System open System.Security.Cryptography let keySize = 1024 // bits let testDataLen = 1000 let iterations = 100 let hashAlg = "SHA1" let timer f = let start = DateTime.Now f() |> ignore let finish = DateTime.Now finish - start let bench () = use rsaSP = new RSACryptoServiceProvider(keySize) let rnd = Random() let data = Array.create testDataLen 0uy rnd

Get and use connection string from App.config F# AppSettings provider

风格不统一 提交于 2019-12-10 23:07:58
问题 I've scoured the net for hours and can't do it, so I'm hoping someone can help me with this one. I've tried to use App.Config directly but constantly had null return. So I've turned to an AppSetting typerprovider. This does return the string expected but I have a problem that no-one so far (via google) has an answer for. open System.Linq open FSharp.Data.Sql open MySql.Data open FSharp.Configuration type Settings = AppSettings<"App.config"> let c = Settings.ConnectionStrings.RaspberryPi [

Cyclic function/type dependency in F#

倾然丶 夕夏残阳落幕 提交于 2019-12-10 23:04:44
问题 I have a question about the best way to go about the following I Have a class B, I have a combinator on B, let foo : B -> int. I want the class B to have the combinator encapsulated as a method, so I add it with a type extension. I then later on realize that foo is quite expensive and want to cache it's result with lazy evaluation So I add a huge clutch to the system by passing the combinator as a function to the constructor and then initializing a field with foo = lazy(foo self) in the

STATHREAD as async workflow in F#

社会主义新天地 提交于 2019-12-10 22:47:33
问题 Consider the following code fragment: let t1 = async { return process1() } let t2 = async { return process2() } let t3 = async { return windowsProcess() } let execute = [ t1; t2; t3 ] |> Async.Parallel |> Async.RunSynchronously |> ignore What to do in the case the windowsProcess requires a STATHREAD? Is this possible with this construction? 回答1: If there's a particular thread with a SyncrhonizationContext, e.g. the UI thread, then you could do e.g. // earlier on the UI thread... let syncCtxt

Is possible to define same-named operator for different argument count?

寵の児 提交于 2019-12-10 22:45:35
问题 Is possible to define same-named operator for different argument count? And if it is possible then how? for example I want: let (-) x y = x - y let (-) x = -x Sadly I can't call just -x, I need (-)x to use it but it's yet another sub-question which have no relation with primary question. 回答1: This is not possible with let bindings From MSDN You can redefine the regular arithmetic operators in this manner because the scoping rules for F# dictate that newly defined operators take precedence