爲什麼不允許這樣做?類型(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