Tutorial by Examples

Types can represents various kind of things. It can be a single data, a set of data or a function. In F#, we can group the types into two categories.: F# types: // Functions let a = fun c -> c // Tuples let b = (0, "Foo") // Unit type let c = ignore // Records...
Type abbreviations allow you to create aliases on existing types to give them a more meaningful senses. // Name is an alias for a string type Name = string // PhoneNumber is an alias for a string type PhoneNumber = string Then you can use the alias just as any other type: // Create a recor...
F# uses the type keyword to create different kind of types. Type aliases Discriminated union types Record types Interface types Class types Struct types Examples with equivalent C# code where possible: // Equivalent C#: // using IntAliasType = System.Int32; type IntAliasType = int // ...
Acknowledgement This example is adapted from this article on type inference What is type Inference? Type Inference is the mechanism that allows the compiler to deduce what types are used and where. This mechanism is based on an algorithm often called “Hindley-Milner” or “HM”. See below some of th...

Page 1 of 1