为什么不允许这样做?类型(unit - > unit)的函数是否可以在F#中静态解析类型参数?
type Foo() =
static member Bar() =()
let inline bar<^a>() = //ERROR: unexpected infix operator in pattern
(^a : (static member Bar : unit -> unit)())
//Hypothetical usage: let _ = bar<Foo>()
...但这工作正常吗?
type Foo() =
static member Bar() = new Foo()
let inline bar() : ^a =
(^a : (static member Bar : unit -> ^a)())
let x : Foo = bar()
函数是否具有静态解析类型参数以返回解析类型的实例?
'F#将字符序列<^作为中缀运算符,因此您需要将它们与空格分开+1 – 2016-05-10 11:53:09