These things are shortcuts to each other.
The most fundamental thing is let . This keyword names the materials:
let name = "stuff"
More technically, the let keyword defines an identifier and associates it with a value:
let identifier = "value"
After that, you can use the name and identifier words in your program, and the compiler will know what they mean. Without let there would be no way to name the material, and you would always have to write all your data into a string, instead of referring to chunks of that name.
Now the meanings have different tastes. There are "some string" strings, there are 42 integers, 5.3 floating-point numbers, true , etc. Feature of function is function. Functions are also values, much like strings and numbers. But how do you write a function? You use double quotes to write a string, but what about a function?
Well, to write a function, you use the special word fun :
let squareFn = fun x -> x*x
Here I used the let keyword to define the squareFn identifier and bind this identifier to the value of the function view. Now I can use the word squareFn in my program, and the compiler finds out that whenever I use it, I mean the function fun x -> x*x .
This syntax is technically sufficient, but not always convenient to write. Therefore, to make it shorter, let binding takes on additional responsibility and provides a shorter way to write above:
let squareFn x = x*x
That should do it for let vs fun .
Now the function keyword is just a short form for fun + match . The notation function equivalent to the notation fun x -> match x with , period.
For example, the following three definitions are equivalent:
let f = fun x -> match x with | 0 -> "Zero" | _ -> "Not zero" let fx = // Using the extra convenient form of "let", as discussed above match x with | 0 -> "Zero" | _ -> "Not zero" let f = function // Using "function" instead of "fun" + "match" | 0 -> "Zero" | _ -> "Not zero"