Basic values

In F#, every valid value must have a type, and a value of one type may not be bound to a value of another type. We will declare values in F# using the let keyword. For example, refer to the following piece of code:

    // variable expression 
    let x = 10 
    // function expression 
    let add a b = a + b 

As you learn F#, you will initially spend a lot of time getting the F# type checker to accept your programs. Being patient and analyzing the results with the F# type checker eventually helps you program better; you will later realize that the type checker is your best friend. Some rules about type checking are as follows:

  • Every expression has exactly one type
  • When an expression is evaluated, one of the following two things can happen:
    • It could evaluate ...

Get Mastering F# now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.