Mauricio Scheffer
Mauricio Scheffer

Reputation: 99750

Generic type definition syntax on F#

This is not a big deal, but is there any way in F# to get a generic type definition without calling GetGenericTypeDefinition() ? IComparable<_> is IComparable<object> (or whatever type is inferred) and IComparable<> is a syntax error.

VB.NET

GetType(IComparable(Of ))

C#

typeof(IComparable<>)

F#

typeof<IComparable<_>>.GetGenericTypeDefinition()

Upvotes: 9

Views: 971

Answers (1)

Brian
Brian

Reputation: 118925

You want "typedefof"

printfn "%s" (typedefof<list<int>>).Name

Upvotes: 13

Related Questions