f#-3.0

F# How Async<'T> cancellation works?

夙愿已清 提交于 2019-11-30 23:29:56
问题 I was pretty comfortable with how async cancellations where done in C# with the TPL, but I am a little bit confused in F#. Apparently by calling Async.CancelDefaultToken() is enough to cancel outgoing Async<'T> operations. But they are not cancelled as I expected, they just... vanishes... I cannot detect properly the cancellation and tear down the stack properly. For example, I have this code that depends on a C# library that uses TPL: type WebSocketListener with member x.AsyncAcceptWebSocket

F# operator overloading for conversion of multiple different units of measure

爱⌒轻易说出口 提交于 2019-11-30 17:51:06
I want to be able to do this: let duration = 1<hours> + 2<minutes> + 3<seconds> with the following types and functions (and possibly more units of measure): type [<Measure>] seconds type [<Measure>] minutes type [<Measure>] hours let seconds_per_minute = 60<seconds> / 1<minutes> let minutes_per_hour = 60<minutes> / 1<hours> let minutes_to_seconds minutes seconds = minutes * seconds_per_minute + seconds let hours_to_minutes hours minutes = hours * minutes_per_hour + minutes So basically "hours_to_minutes" should be used for adding hours and minutes, and "minutes_to_seconds" should be used for

F# operator overloading for conversion of multiple different units of measure

三世轮回 提交于 2019-11-30 01:51:33
问题 I want to be able to do this: let duration = 1<hours> + 2<minutes> + 3<seconds> with the following types and functions (and possibly more units of measure): type [<Measure>] seconds type [<Measure>] minutes type [<Measure>] hours let seconds_per_minute = 60<seconds> / 1<minutes> let minutes_per_hour = 60<minutes> / 1<hours> let minutes_to_seconds minutes seconds = minutes * seconds_per_minute + seconds let hours_to_minutes hours minutes = hours * minutes_per_hour + minutes So basically "hours

groupby multiple columns in a F# 3.0 query

断了今生、忘了曾经 提交于 2019-11-30 01:19:22
Just trying out F# 3.0 and hit a bit of a wall when it comes to grouping by multiple columns. The obvious thing to try was query { for d in context.table do groupBy (d.col1,d.col2) into g select (g.Key) } But I get a "Only parameterless constructors and initializers are supported in LINQ to Entities." exception. I can't seem to find an example on msdn http://msdn.microsoft.com/en-us/library/hh225374(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/hh361035(v=vs.110).aspx And I realize my question is similar to " Entity Framework and Anonymous Types in F# " but it seems to be powerpack/F

Is there a way to install F# 3.0 without Visual Studio?

泪湿孤枕 提交于 2019-11-28 09:04:21
I was hoping to upgrade to F# 3.0 but I can't find either a packaged F# 3.0 compiler on Microsoft site, nor if there is an express version to use. Is it possible to install F# 3.0 for use from the command line or a simple IDE and if so, how? The standalone version of F# is not available yet, but F# tools for Visual Studio Express have been released just 2 days ago, so you can get F# 3.0 for free. Announcing F# Tools for Visual Studio Express 2012 for Web! As far as I know, there are definitely plans for open-source release (that can be integrated with MonoDevelop) and it would make sense to

Providing a Discriminated Union from an F# Type Provider

痴心易碎 提交于 2019-11-28 07:59:29
问题 I've gotten the basics of type providers such as creating a type let thisAssembly = Assembly.GetExecutingAssembly() let t = ProvidedTypeDefinition( thisAssembly,namespaceName, xType.Attribute(xname "name").Value, baseType = Some typeof<obj>) but I need to be able to define record types and DU types is there any way to do this with type providers? 回答1: Unfortunately, it's not possible to define any F# specific types like Discriminated Unions, Records, or Modules, in a type provider, only

Is there a way to install F# 3.0 without Visual Studio?

假装没事ソ 提交于 2019-11-27 02:37:37
问题 I was hoping to upgrade to F# 3.0 but I can't find either a packaged F# 3.0 compiler on Microsoft site, nor if there is an express version to use. Is it possible to install F# 3.0 for use from the command line or a simple IDE and if so, how? 回答1: The standalone version of F# is not available yet, but F# tools for Visual Studio Express have been released just 2 days ago, so you can get F# 3.0 for free. Announcing F# Tools for Visual Studio Express 2012 for Web! As far as I know, there are