Basics 01 - The Ceremonial Hello World
Here it comes, the Hello World for F#:
Learning-FSharp/Ch01-HelloWorld/Program.fs
Check out all the comments that are placed in the source file.
Key Ideas
Multi-line comments:
(* comments *)
Single-line comments:
// comments
The program entry point:
let main args =
The entry point should be decorated with:
[<EntryPoint>]
Pamaters that are passed to a function are separate by space, not a comma
There are no opening/closing brackets for the function body; no semi-colons for line ending
The function body should be indented
The return value of a function is the last expression in the function body
.NET library is accessible from F#
Compilation Order in F
Unlike C#, compilation order in F# is important
This means:
The order in which files are compiled
The order in which content within a file is present
Simply put, if A refers to B, B should be compiled before A
To change the order of files, edit the
.fsproj
fileWithin a file, place namespaces, modules, types and functions accordingly
If within a file there is circular dependence, use
rec
(recurring, more on this later)The
main
function, the entry point should be the last declaration in the last file
If you have reached so far, congratulations.
Keep reading!