f#

In F# how can I produce an expression with a type of Func<obj>?

旧时模样 提交于 2019-12-09 14:25:31
问题 I'm working with an api that requires a value of type Func. (Specifically, I'm trying to call ModelMetadataProviders.Current.GetMetadataForType(). How can I construct that value in F#? 回答1: When calling a method that takes any delegate of the Func you shouldn't need to explicitly create the delegate, because F# implicitly converts lambda expressions to delegate type (in member calls). I think that just calling the method with lambda function should work (if it doesn't, could you share the

F# Type Providers vs. Lisp macros

北慕城南 提交于 2019-12-09 14:21:42
问题 I've been reading about F# 3.0 type providers (e.g. here) and it seems that they are based on a kind of compile-time code generation. In that respect I was wondering how they compare against Lisp macros. It would seem that both F# 3.0 type providers and Lisp macros allow user code to execute at compile time and introduce new types available to the compiler. Can anyone shed some light on the issue and nuances involved? 回答1: There is some overlap between F# type providers and meta-programming

Can the F# core libs be SQLCLR-approved?

十年热恋 提交于 2019-12-09 12:36:22
问题 According to this thread, F# Core must be SQLCLR-approved for assemblies to be marked SAFE . Is this planned? Can it even be done? 回答1: I believe it can be done. However, F# core library is the sole property of Microsoft. This means you can't modify its code and recompile it to match and comply with SQLCLR SAFE. I suggest you add suggestion to Microsoft using Microsoft's connect website. Microsoft connect is at: http://connect.microsoft.com (you have to register and have email account on live

How to store state in an F# Akka.NET Actor?

二次信任 提交于 2019-12-09 10:20:28
问题 In C# ReceiveActor s I can just have state as private fields in the class. How should I do this in an idiomatic way with the F# API? Is this a good idea? Any alternatives? let handleMessage (mailbox: Actor<'a>) msg = let mutable i = 1 match msg with | Some x -> i <- i + x | None -> () 回答1: The way you've proposed is entirely appropriate as a means of storing the state within the actor. The concurrency constraints of only processing 1 message at any time means that it's not possible to get

What is the case against F#? [closed]

会有一股神秘感。 提交于 2019-12-09 10:05:07
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . Straightforward C#/Java code is extremely difficult to parallelize, multi-thread, etc. As a result, straightforward C#/Java code will use less and less of the total processing power on a box (because everything is now going to be multi-core). Solving this problem in C# and

How does F# inline work?

断了今生、忘了曾经 提交于 2019-12-09 08:17:27
问题 With F# it is my understanding that you can use the inline keyword to perform type specialization at the call site. That is:: val inline (+) : ^a -> ^b -> ^c when (^a or ^b) : (static member (+) : ^a * ^b -> ^c) Constrains that ^a or ^b must have a static member like op_Addition , or one of the built in primitives, that can be used to fill in the gap. So if you have a method that has a + and you pass in an int and a short as parameters it unwraps + to an instruction to use the built in

F# Type declaration possible ala Haskell?

那年仲夏 提交于 2019-12-09 07:38:23
问题 I've looked a number of sources: it seems not possible to declare a type definition in F# ala Haskell: ' haskell type def: myFunc :: int -> int I'd like to use this type-def style in F#--FSI is happy to echo back to me: fsi> let myType x = x +1;; val myType : int -> int I'd like to be explicit about the type def signature in F# as in Haskell. Is there a way to do this? I'd like to write in F#: //invalid F# myFunc : int -> int myFunc x = x*2 回答1: If you want to keep readable type declarations

F# generate a sequence/array of dates

我怕爱的太早我们不能终老 提交于 2019-12-09 06:32:10
问题 In F# I can easily do let a = [1 .. 10];; Then why can't I do let a = DateTime.Parse("01/01/2012") let b = DateTime.Parse("01/01/2020") let dateList = [a .. b] It gives an error Type constraint mismatch. The type DateTime is not compatible with type TimeSpan 回答1: There are two problems - firstly you need to specify the interval you want to use between elements of the list. This would be a TimeSpan , however it does not have a static Zero member. This constraint is required by the skip range

(How) can I make this monadic bind tail-recursive?

会有一股神秘感。 提交于 2019-12-09 05:54:50
问题 I have this monad called Desync - [<AutoOpen>] module DesyncModule = /// The Desync monad. Allows the user to define in a sequential style an operation that spans /// across a bounded number of events. Span is bounded because I've yet to figure out how to /// make Desync implementation tail-recursive (see note about unbounded recursion in bind). And /// frankly, I'm not sure if there is a tail-recursive implementation of it... type [<NoComparison; NoEquality>] Desync<'e, 's, 'a> = Desync of (

will there be a F# express edition?

自作多情 提交于 2019-12-09 05:08:57
问题 I know VS2010 is coming out soon and that usually corresponds to a update of the express versions does anyone know if they are going to make a separate F# express suite? 回答1: From this page: Don says: Our current plan is not to have a separate express edition, but instead to continue to provide a version of the development tools that can either be used as a standalone command line compiler, or as an add-in, initially to Visual Studio 2008. UPDATE Today a new release of F# includes an