F#上的泛型类型定义语法

Mau*_*fer 9 f#

这不是什么大问题,但在F#中有没有办法在不调用GetGenericTypeDefinition()的情况下获得泛型类型定义?IComparable<_>是IComparable<object>(或推断出任何类型)并且IComparable<>是语法错误.

VB.NET

GetType(IComparable(Of ))
Run Code Online (Sandbox Code Playgroud)

C#

typeof(IComparable<>)
Run Code Online (Sandbox Code Playgroud)

F#

typeof<IComparable<_>>.GetGenericTypeDefinition()
Run Code Online (Sandbox Code Playgroud)

Bri*_*ian 13

你想要"typedefof"

printfn "%s" (typedefof<list<int>>).Name
Run Code Online (Sandbox Code Playgroud)