Indentation as Program scope in F#

C# uses the flower bracket “{” and “}” to identify the block or scope of the function or program . F# is quite different in the sense that it uses the indentation or tab to identify the program scope or blocks.

Below is a code snippet demonstrating the indentation used for a program in F#

open System
let main argv =
    let Variable1  = "developerpublish - F# Tips & Tricks"
    let retval = Console.ReadLine()

If there is an issue with the indentation , you will be prompted with the following error messages . To resolve the issue , we can verify the indentation of the program and fix it.

Incomplete value or function definition. If this is in an expression, the body of the expression must be indented to the same column as the ‘let’ keyword”

Unexpected identifier in binding. Expected incomplete structured construct at or before this point or other token.


Leave a Reply