Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generic type definition syntax on F#

Tags:

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()
like image 886
Mauricio Scheffer Avatar asked Oct 30 '09 20:10

Mauricio Scheffer


People also ask

What is generic syntax?

The syntax for a generic method includes a list of type parameters, inside angle brackets, which appears before the method's return type. For static generic methods, the type parameter section must appear before the method's return type.

What is generic datatype?

Data types from the source and target systems you use are mapped to and mapped from a core set of generic data types in Oracle Cloud Infrastructure Data Integration.

How do you define a generic type in TypeScript?

Generics allow creating 'type variables' which can be used to create classes, functions & type aliases that don't need to explicitly define the types that they use. Generics makes it easier to write reusable code.


1 Answers

You want "typedefof"

printfn "%s" (typedefof<list<int>>).Name
like image 63
Brian Avatar answered Oct 02 '22 19:10

Brian