In F#, indentation is syntax, not decoration. Indenting code creates a scope, which controls where names are accessible and how long they remain available. This removes much of the brace-and-semicolon boilerplate used by more verbose styles while keeping the structure visible. section 3.1.1 section 3.4
A function body must be indented farther than its definition. Nested bindings remain inside that body, while the final indented expression supplies the function result. Align related expressions consistently so that the intended scope is immediately clear. section 3.1.1 section 3.4
Listing 3.1 F# syntax basics
let addTenThenDouble theNumber = #1
let addedTen = theNumber + 10 #2
let answer = addedTen * 2 #3
printfn $"({theNumber} + 10) * 2 is {answer}"
let website = System.Uri "https://fsharp.org" #4
answer #5
The nested bindings, output call, object creation, and final result are all indented beneath the function definition, placing them in one function scope without braces or explicit return syntax. section 3.1.1
A small indented function
let greetPerson name age = $"Hello, {name}. You are {age} years old" The greeting expression is indented under greetPerson, so it forms the function body. Use spaces or tabs, but ensure the body begins at least one space beyond the definition; four spaces is a common convention. section 2.5.5
When writing indented F# code:
- Place the body of each function farther right than its definition. section 2.5.5
- Use indentation to keep local let bindings within the scope that needs them. section 3.4
- Prefer the concise layout when types, braces, semicolons, and return statements add no needed meaning. section 3.1.1





