Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use F#'s typedefof<'T> vs. typeof<'T>?

Tags:

Can someone clarify when to use typedefof<'T> vs. typeof<'T>?

Both typedefof<System.String> and typeof<System.String> return the same Type instance.

However, they return different instances and different information for System.Collections.Generic.List<_>.

Can I think of typedefof as a new and improved typeof? Should I just switch to always using typedefof? Or is it more subtle than that?

like image 792
Wallace Kelly Avatar asked Jun 13 '18 13:06

Wallace Kelly


People also ask

When should we use F-test?

The F-test is used by a researcher in order to carry out the test for the equality of the two population variances. If a researcher wants to test whether or not two independent samples have been drawn from a normal population with the same variability, then he generally employs the F-test.

What is the F-statistic used for?

F statistic also known as F value is used in ANOVA and regression analysis to identify the means between two populations are significantly different or not. In other words F statistic is ratio of two variances (Variance is nothing but measure of dispersion, it tells how far the data is dispersed from the mean).

What is the difference between F value and F crit?

Using The F Statistic. In your F test results, you'll have both an F value and an F critical value. The value you calculate from your data is called the F Statistic or F value (without the “critical” part). The F critical value is a specific value you compare your f-value to.

What is a good F value?

The F-statistic provides us with a way for globally testing if ANY of the independent variables X1, X2, X3, X4… is related to the outcome Y. For a significance level of 0.05: If the p-value associated with the F-statistic is ≥ 0.05: Then there is no relationship between ANY of the independent variables and Y.


1 Answers

This ought to illustrate the difference. When you use typeof, the compiler infers type arguments and constructs a concrete type. In this case, the inferred type argument is System.Object:

let t1 = typeof<System.Collections.Generic.List<_>>
let t2 = typedefof<System.Collections.Generic.List<_>>

printfn "t1 is %s" t1.FullName
printfn "t2 is %s" t2.FullName

Output:

t1 is System.Collections.Generic.List`1[[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
t2 is System.Collections.Generic.List`1

Because typeof can only return a constructed type, typedefof is necessary if you need a type object representing a generic type definition.

like image 90
phoog Avatar answered Oct 31 '22 04:10

phoog