A value may be missing for an ordinary reason: a customer ID might not exist, or a search might find no match. F# represents that possibility with `option<'T>`, a generic discriminated union with two cases: `Some value` and `None`. An `int option` is a different type from an `int`, so a function cannot silently treat a possibly missing number as a mandatory one. section 9.1.2 section 9.1.3
Handle both outcomes
`let presentNumber : int option = Some 10` and `let missingNumber : int option = None` have the same type. To produce a description, match both cases: ```fsharp let describe number = match number with | Some value -> $"The number is {value}" | None -> "There is no number" ``` Pattern matching makes the missing-value decision explicit. Avoid using an option’s `.Value` member in application code: it throws if the value is `None`. section 9.1.2
When the next operation only transforms a present value, repeating a match adds boilerplate. `Option.map` unwraps `Some`, applies a function, and wraps its result in `Some`; `None` stays `None`. For an optional customer, `optionalCustomer |> Option.map (fun customer -> customer.Age)` produces an optional age. The age-reading function need not know about options, and mapping can be chained with further transformations. section 9.1.3
Choose the operation that matches what missing data means:
- Use a match or `Option.defaultValue` when you need to decide what `None` means; use `Option.map` or `Option.bind` while continuing to work with optional data. section 9.2.6
- Prefer `List.tryFind` to `List.find` when no match is expected sometimes: it returns an option rather than throwing. Use `choose` to keep the present results from a collection of optional results. section 9.1.6
- Use `Result` when failure needs an explanation, and reserve exceptions for situations where there is no useful recovery path. section 9.2.6
let parseOption parser (value:string) = #1
match parser value with
| true, v -> Some v
| false, _ -> None
let parseIntOption = parseOption System.Int32.TryParse #2
let maybeANumber = parseIntOption "123" #3
A small wrapper turns a .NET `TryParse` outcome into `Some` on success or `None` on failure, so callers work with an option. section 11.1.7
At .NET boundaries, reference values can be null and value types can use `Nullable<'T>`. Convert them with `Option.ofObj` or `Option.ofNullable`, keep options inside F# domain code, and convert back when calling APIs that require .NET representations. An option should describe possible absence—not serve as a substitute for validating a mandatory value. section 9.1.5









