f#

F# Interactive CsvProvider not defined

允我心安 提交于 2019-12-24 00:34:19
问题 I'm loading FSharp.Data in the interactive console. The library is loaded without any problem: > #r "FSharp.Data.dll";; --> Referenced 'C:\Users\pw\AppData\Local\Temp\FSharp.Data.dll' (file may be locked by F# Interactive process) > open FSharp.Data;; However, when I'm trying to initialize CsvProvider (defined in FSharp.Data ) I get the error message saying the type is not defined: > type Stocks = CsvProvider<"C:\Users\pw\Downloads\msft.csv">;; type Stocks = CsvProvider<"C:\Users\pw\Downloads

How can unify the signature of this member method and the inline function

点点圈 提交于 2019-12-24 00:25:24
问题 given this code type Baz = Baz of int with static member bar f (Baz(b)) = f b let inline foo< ^T, ^U when ^T : (static member bar : (^U -> ^T) -> ^T -> ^T)> (f:(^U -> ^T)) (t:^T) : ^T = (^T : (static member bar : (^U -> ^T) -> ^T -> ^T) f, t ) let x = foo (fun x -> (Baz 0)) (Baz 1) I get this error error FS0043: Method or object constructor 'bar' not found I assume that signature of my static member can not really be unified to (^U -> ^T) -> ^T -> ^T How can I solve this? 回答1: Looking at the

accessing dynamic objects in F#

吃可爱长大的小学妹 提交于 2019-12-24 00:03:18
问题 I'm parameterizing some linq queries, and ended up using dynamic linq. Initially I had some trouble extracting the data from the dynamic objects it created but I managed to extract it using FSharp. InteropDynamic, regarding a better way to parameterize linq queries I plan to post another question. My question is . Is this the best way to access dynamic linq and/or dynamic objects (memory and speed wise?). When I first use it FSI gives me a message. Binding session to '..\..\packages\Dynamitey

F# Event Handler using XAML markup

两盒软妹~` 提交于 2019-12-23 23:40:50
问题 Now that I have a Custom Routed Event, how can I specify a handler in XAML? <Window.Resources> <Style TargetType="Grid"> <Setter Property="funk:Tap.Handler" Value="{Binding TapHandler}"/> </Style> </Window.Resources> Allowing: UIElements to handle bubbling or tunneling RoutedEvents, not just the Controls raising them The use of implicit Styles, eliminating the need to wire the event for each UIElement of a certain Type Change of handler based on logic in ViewModel a View with no code-behind

How can I have an actor running on one process send a message to another actor running on a separate process?

[亡魂溺海] 提交于 2019-12-23 23:13:11
问题 I want to have actors running on various processes (or nodes) send messages to other actors running off of different processes (or nodes), all while maintaining fault-tolerance and load balancing. I am currently attempting to use Akka.Cluster's Sharding feature to accomplish this. However, I am not sure how to accomplish this... I have the following code that reflects my seed node: let configurePort port = let config = Configuration.parse (""" akka { actor { provider = "Akka.Cluster

How do I implement multiple argument generation using FsCheck?

拟墨画扇 提交于 2019-12-23 22:40:03
问题 How do I implement multiple argument generation using FsCheck? I implemented the following to support multiple argument generation: // Setup let pieces = Arb.generate<Piece> |> Gen.filter (isKing >> not) |> Arb.fromGen let positionsList = Arb.generate<Space list> |> Arb.fromGen I then used these arguments to test the behavior of a function that's responsible for generating move options for a given checker: // Test Prop.forAll pieces <| fun piece -> Prop.forAll positionsList <| fun

Why does pattern matching fail on an exception in this case?

寵の児 提交于 2019-12-23 22:16:11
问题 I have this simple exception hierarchy: type FirstLevelException(msg) = inherit System.Exception (msg) type SecondLevelException(msg, inner) = inherit System.Exception (msg, inner) type ThirdLevelException(msg, inner) = inherit System.Exception (msg, inner) and these three (dummy) functions: member this.FirstFunction a = raise (new FirstLevelException("one")) member this.SecondFunction a = try this.FirstFunction a with | :? FirstLevelException as ex -> raise (new SecondLevelException("two",

Delete third element in F# list

梦想的初衷 提交于 2019-12-23 21:10:04
问题 I am writing a function to return a list minus the third value. Here is my current code: let listString = [ "1"; "2"; "3"; "4" ];; let del3 (listA :'a) = [listA.Head; listA.Tail.Head] @ [listA.Tail.Tail.Tail];; del3 listString and I am getting the error: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved. What should I

Incorrect IntelliSense XML generated for F# record values (VS2013)

亡梦爱人 提交于 2019-12-23 21:00:20
问题 Update: as noted in the comments, this is a bug. I've reported it to Microsoft and it has been routed to a VS development team for investigation. I'll update this answer if and when there's news. Further update: a fix has been committed to the project on CodePlex, yay! Given a record type: namespace Rather.Deep.Namespace type TestRecord = { /// Property summary Prop : string } VS2013 generates the following IntelliSense XML for this field: <member name="F:Rather.Deep.Namespace.Rather.Deep

This expression has type int but is here used with type unit

こ雲淡風輕ζ 提交于 2019-12-23 20:19:18
问题 I'm trying to get the exact equivalent (not functional) of this vb.net code in F#: Function FastPow(ByVal num As Double, ByVal exp As Integer) As Double Dim res As Double = 1 If exp < 1 Then If exp = 0 Then Return res exp = -exp num = 1 / num End If Do While exp > 1 If exp Mod 2 = 1 Then res = res * num num = num * num exp = exp >> 1 Loop Return res * num End Function I wrote this: let FastPow num exp = let mutable ex = exp let mutable res = 1 let mutable n = num if ex < 1 then if ex = 0 then