In addition to type abbreviations, there are two useful things you need to know about F # types. First of all, there are two ways to write generic type names. One way is to use the OCaml syntax, and a second way is to use the .NET syntax:
- When using the .NET syntax, you write
array<'T> or, for example, OtherType<'T1, 'T2> (for types with more than one type parameter). - In OCaml syntax, the same thing is written as
'T array or ('T1, 'T2) OtherType
The two entries are equivalent - when you declare a type value annotated using the .NET syntax, you can assign it a value annotated using the OCaml syntax. 'T[] are special notations for arrays, but this explains why array<'T> matches 'T array .
Secondly, F # uses the bad name bit for floating point types. This is probably due to compatibility with OCaml, but this can easily confuse .NET programmers:
- The F # float type corresponds to
System.Double in .NET (which is called double in C #) - F # float32 type corresponds to
System.Single in .NET (which is called float in C #)
As @kvb points out, double is another type alias for the System.Double type.
Tomas petricek
source share